Referring to forms using VBA

cstanley

Registered User.
Local time
Today, 02:15
Joined
May 20, 2002
Messages
86
Hello all,

I've got a form with a list box and a button that opens another form. If you double-click on the list box, the form opens to that record. If you click the "add new record" button, I want the form to open blank and change the recordsource to the table where I want the new data to come from. So, I put code into the button to set the list box value to Null when pressed, and I put the following code into the second form:



Private Sub Form_Load()
If IsNull(frmpeople.lstPeople) Then
Me.RecordSource = tblpeople
Forms!frmAddModifyPeople.DataEntry = True
End If
End Sub

But, it doesn't like my IsNull syntax for some reason - it won't recognize the form that I have listed there as an object. All the names are correct - what am I doing wrong?

Thanks,

Chris:confused:
 
You will have to use a full reference as you did later in the code.

Thus:

If IsNull(Forms!frmpeople.lstPeople) Then


You may need to account for the possibility of frmpeople not being open. If this occurs, you will return an error as Access can not find a closed object.

HTH

Brad.
 

Users who are viewing this thread

Back
Top Bottom