Hi,
I use the following code on my search box. But I want it to goto the searched record in the form not filter it, how do I achieve this?
I use the following code on my search box. But I want it to goto the searched record in the form not filter it, how do I achieve this?
Code:
Private Sub cmdSearch_Click()
If Len(cboSearchField) = 0 Or IsNull(cboSearchField) = True Then
MsgBox "You must select a field to search."
ElseIf Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
MsgBox "You must enter a search string."
Else
'Generate search criteria
GCriteria = cboSearchField.Value & " LIKE '" & txtSearchString & "'"
'Filter frmCustomers based on search criteria
Form_frmSitesMain.RecordSource = "select * from tblSites where " & GCriteria
Form_frmSitesMain.Caption = "tblSites (" & cboSearchField.Value & " contains '*" & txtSearchString & "*')"
'Close frmSearch
DoCmd.Close acForm, "frmSearch"
MsgBox "Results have been filtered."
End If
End Sub