I'm experiencing a problem with DoCmd.GoToRecord.
I have a form with a listbox of records. I want to enable the user to double-click on a record and for another form to open to it.
The following code uses an Contact_ID to look for the record. However, it's possible to have the Contact_ID value greater than the total number of records (due to deleted records). Therefore, I receive an error when I try to pull a record with a Contact_ID of '402' when there are only 399 records.
Any help would be appreciated.
Private Sub LB_Contacts_DblClick(Cancel As Integer)
x = LB_Contacts.Column(6)[/color] ' x assigned Contact_ID
DoCmd.OpenForm "Frm_Contacts", acNormal
DoCmd.GoToRecord acDataForm, "Frm_Contacts", acGoTo = x
End Sub
-illini
I have a form with a listbox of records. I want to enable the user to double-click on a record and for another form to open to it.
The following code uses an Contact_ID to look for the record. However, it's possible to have the Contact_ID value greater than the total number of records (due to deleted records). Therefore, I receive an error when I try to pull a record with a Contact_ID of '402' when there are only 399 records.
Any help would be appreciated.
Private Sub LB_Contacts_DblClick(Cancel As Integer)
x = LB_Contacts.Column(6)[/color] ' x assigned Contact_ID
DoCmd.OpenForm "Frm_Contacts", acNormal
DoCmd.GoToRecord acDataForm, "Frm_Contacts", acGoTo = x
End Sub
-illini