I have a form that uses criteria from another form (fProspects) as part of
the SQL for it's record source. I've added the following code to Cancel the
form from opening if fProspects isn't open, but it still prompts for the
fields in fProspects before closing the form.
Any ideas how I can get it to Cancel the open before trying to create the
data connection?
Private Sub Form_Open(Cancel As Integer)
'close if the Prospects form is not loaded
If CurrentProject.AllForms("fProspects").IsLoaded = False Then
Cancel = True
End If
End Sub
stefan hoffmann - 21 Dec 2005 13:41 GMT
hi,
> Any ideas how I can get it to Cancel the open before trying to create the
> data connection?
Use a unbound form and set the record source in the code.
> Private Sub Form_Open(Cancel As Integer)
> 'close if the Prospects form is not loaded
> If CurrentProject.AllForms("fProspects").IsLoaded = False Then
> Cancel = True
Else
me.RecordSource = "SELET * FROM ... WHERE ID = " & fProspects![ID]
> End If
> End Sub
mfG
--> stefan <--
Rick Brandt - 21 Dec 2005 13:42 GMT
> I have a form that uses criteria from another form (fProspects) as
> part of the SQL for it's record source. I've added the following
[quoted text clipped - 14 lines]
>
> End Sub
In design view of the form remove the RecordSource. In your Open code set
the RecordSource when the other form is open.

Signature
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com