i want to run a search for members (stored in the db) from a member form based on the member's surname. i found some vba code on this but it doesnt work - it says i have a label undefined and points to: GoTo LastName_Exit
Private Sub cmdSearch_Click()
GoTo LastName_Exit 'call sub procedure
End Sub
Private Sub cmdSearch_Exit(Cancel As Integer)
Dim szLastName As String, szCrit As String
' retrieve user entered search criteria
szLastName = Nz(Me!LastName, "")
'determine if user entered criteria
If Len(szLastName) < 1 Then
MsgBox "you must first enter a last name to search on."
Cancel = True
Else
'build criteria
szCrit = BuildCriteria("Surname", dbText, szLastName)
'apply the filter to the form
DoCmd.ApplyFilter , szCrit
End If
LastName.Value = ""
Surname.SetFocus
End Sub
Private Sub cmdSearch_Click()
GoTo LastName_Exit 'call sub procedure
End Sub
Private Sub cmdSearch_Exit(Cancel As Integer)
Dim szLastName As String, szCrit As String
' retrieve user entered search criteria
szLastName = Nz(Me!LastName, "")
'determine if user entered criteria
If Len(szLastName) < 1 Then
MsgBox "you must first enter a last name to search on."
Cancel = True
Else
'build criteria
szCrit = BuildCriteria("Surname", dbText, szLastName)
'apply the filter to the form
DoCmd.ApplyFilter , szCrit
End If
LastName.Value = ""
Surname.SetFocus
End Sub