SyBeerianTyGRRRR
Technical User
Hi folks,
I have a form in my db in which i store all my business contacts name, address, phone no etc. The components are as follows:
frmContacts (the Form !!)
tblContacts (Record Source)
I have put a record selector combo box at the top of frmContacts with the following code attached to the After Update event procedeure:
Private Sub cboContactNameSearchList_AfterUpdate()
On Error GoTo ErrorHandler
Dim strSearch As String
strSearch = "[LastName] = " & Chr$(39) & _
Me![cboContactNameSearchList] & Chr$(39)
'Find the record that matches the control
Me.Requery
Me.RecordsetClone.FindFirst strSearch
Me.Bookmark = Me.RecordsetClone.Bookmark
ErrorHandlerExit:
Exit Sub
ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
End Sub
This works fine for most of the records stored but the problem is i only have first names for some of the people listed and the code above will only select records where a [LastName] value is present.
Can someone tell me how to change this code so that selecting one of these [FirstName] only contacts in the combo box will go to that record in the form???
Could it be something like:
strSearch = "[LastName]" & "[FirstName]" = " & Chr$(39) & _
???
Or alternatively do i just need to change some or one of the properties in Design View to enable this.
Any assistance would be greatly appreciated.
Stu
UK
I have a form in my db in which i store all my business contacts name, address, phone no etc. The components are as follows:
frmContacts (the Form !!)
tblContacts (Record Source)
I have put a record selector combo box at the top of frmContacts with the following code attached to the After Update event procedeure:
Private Sub cboContactNameSearchList_AfterUpdate()
On Error GoTo ErrorHandler
Dim strSearch As String
strSearch = "[LastName] = " & Chr$(39) & _
Me![cboContactNameSearchList] & Chr$(39)
'Find the record that matches the control
Me.Requery
Me.RecordsetClone.FindFirst strSearch
Me.Bookmark = Me.RecordsetClone.Bookmark
ErrorHandlerExit:
Exit Sub
ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
End Sub
This works fine for most of the records stored but the problem is i only have first names for some of the people listed and the code above will only select records where a [LastName] value is present.
Can someone tell me how to change this code so that selecting one of these [FirstName] only contacts in the combo box will go to that record in the form???
Could it be something like:
strSearch = "[LastName]" & "[FirstName]" = " & Chr$(39) & _
???
Or alternatively do i just need to change some or one of the properties in Design View to enable this.
Any assistance would be greatly appreciated.
Stu
UK