Private Sub button_Search_Click()
On Error GoTo Err_button_Search_Click
Dim boo As Boolean
Dim searchString As String
Select Case Frame_OptionGroup
'snipped for brevity
Case 3
If (Not IsNull(LookupBox_AgencyName)) Then
searchString = "[AgencyName] Like '*" & Me.LookupBox_AgencyName & "*'"
Else
MsgBox ("You must enter a name to search for.")
boo = True
End If
'snipped for more brevity
End Select
If (Not boo) Then
Application.Echo False
DoCmd.Hourglass True
DoCmd.OpenForm "Contacts", , , searchString
DoCmd.Close acForm, "Search for Contact"
Application.Echo True
DoCmd.Hourglass False
End If
Exit_button_Search_Click:
Exit Sub
Err_button_Search_Click:
MsgBox Err.Description
Resume Exit_button_Search_Click
End Sub
Private Sub ParticipantID_Lookup_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Dim PIL As String
If (IsNull(Me.ParticipantID_Lookup)) Or (Me.ParticipantID_Lookup = "") Then Exit Sub
'Include check for Len(ParticipantID) = 6
PIL = Left(Me.ParticipantID_Lookup, 6)
If (Len(PIL) < 6) Then
MsgBox ("Make sure the ParticipantID has 6 characters.")
Exit Sub
End If
Set rs = Me.Recordset.Clone
rs.FindFirst "[ParticipantID] = '" & PIL & "'"
If rs.Nomatch = True Then
MsgBox "No matching record found"
Else
'Go to the matching record
Me.Bookmark = rs.Bookmark
End If
Me.ParticipantID_Lookup.Requery
Set rs = Nothing
End Sub