Hi,
I keep trying to run this search script below, but it keeps returning a compile error. are there any gurus out there that can figure it out. I have tried all weekend and cant see what it is:
I keep trying to run this search script below, but it keeps returning a compile error. are there any gurus out there that can figure it out. I have tried all weekend and cant see what it is:
Code:
Private Sub cmdSearch_Click()
Dim strsiteRef As String
Dim strSearch As String
'Check txtSearch for Null value or Nill Entry first.
If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a Valid Site Code!", vbOKOnly, "Oops Something Was Wrong!"
Me![txtSearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------
'Performs the search using value entered into txtSearch
'and evaluates this against values in siteid
DoCmd.ShowAllRecords
DoCmd.GoToControl ("sitesid")
DoCmd.FindRecord Me!txtSearch
txtSearch.SetFocus
strsiteRef = sitesid.Text
txtSearch.SetFocus
strSearch = txtSearch.Text
'If matching record found sets focus in siteid and shows msgbox
'and clears search control
If strsiteRef = strSearch Then
MsgBox "Match Found For Side Code: " & strSearch, , "Your site has been found!"
sitesid.SetFocus
txtSearch = ""
'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For Site: " & strSearch & " - No Site Found Please Try Again.", _
, "OOPS NO SITE FOUND!"
txtSearch.SetFocus
End If
End Sub