T
Tom
I have a form that contains only a combo box. Once a selection (Last Name)
is selected from the combo box, it then brings up a detailed customer
record.
The code for the combo box is:
*******************************************
Private Sub cboCompany_AfterUpdate()
' Record Selection
If Not IsNull(Me.cboCompany) Then
If Me.Dirty Then
Me.Dirty = False
End If
Set rs = Me.RecordsetClone
rs.FindFirst "[Last] = """ & Me.cboCompany & """"
If rs.NoMatch Then
MsgBox "Is this a New Record?"
Else
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End If
' Open sfrmCustomers
On Error GoTo Err_Command01_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "sfrmContacts"
stLinkCriteria = "[Last]=" & "'" & Me![cboCompany] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command01_Click:
Exit Sub
Err_Command01_Click:
MsgBox Err.Description
Resume Exit_Command01_Click
End Sub
*******************************************
I now want allow to see the first name in addition to the lastname. I
increased the column count to 2 (on the Format tab) of the form.
So far so good... however, if I have multipe records where the last name
e.g. begins with "Smith" then I have will pull up the 1st record of all of
the "Smith" records (even though I selected the e.g. 3rd Smith record.
My question is... how do I edit the function above so that it not only
"looks" at the first column (Last Name) but also the second column (First
Name).
Any advice is appreciated.
is selected from the combo box, it then brings up a detailed customer
record.
The code for the combo box is:
*******************************************
Private Sub cboCompany_AfterUpdate()
' Record Selection
If Not IsNull(Me.cboCompany) Then
If Me.Dirty Then
Me.Dirty = False
End If
Set rs = Me.RecordsetClone
rs.FindFirst "[Last] = """ & Me.cboCompany & """"
If rs.NoMatch Then
MsgBox "Is this a New Record?"
Else
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End If
' Open sfrmCustomers
On Error GoTo Err_Command01_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "sfrmContacts"
stLinkCriteria = "[Last]=" & "'" & Me![cboCompany] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command01_Click:
Exit Sub
Err_Command01_Click:
MsgBox Err.Description
Resume Exit_Command01_Click
End Sub
*******************************************
I now want allow to see the first name in addition to the lastname. I
increased the column count to 2 (on the Format tab) of the form.
So far so good... however, if I have multipe records where the last name
e.g. begins with "Smith" then I have will pull up the 1st record of all of
the "Smith" records (even though I selected the e.g. 3rd Smith record.
My question is... how do I edit the function above so that it not only
"looks" at the first column (Last Name) but also the second column (First
Name).
Any advice is appreciated.