searching

plonker

Registered User.
Local time
Today, 09:10
Joined
Mar 14, 2003
Messages
19
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
 
You can delete the first three lines as they don't actually do anything.
 
Why did you put the code on the command button's Exit event? All that code would function better on the OnClick() event
 
the sub procedure should have been called Private Sub LastName_Exit(Cancel As Integer)

I also tried it in the click event but that didnt work - please help
 

Users who are viewing this thread

Back
Top Bottom