MS Access Search Form - TechRepublic
Question
June 13, 2008 at 08:17 AM
earthenfairie

MS Access Search Form

by earthenfairie . Updated 18 years ago

I’m hoping someone can help. I decided to cut back my detailed search form since we have many users that are not very adept at computers. I’ve since instilled a very easy user friendly search form that is utilized through a comand button on the exact form they’re trying to search. We some success right in the beginning and everyone was put at ease by how simple it was. However, recently it started poping up some run time errors. I’m not sure what is wrong with the coding as it worked for a short time at initialization. Any insight would be helpful and greatly appreciated. Thanks.

The Coding is as follows:

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 search criteria!”

Else

‘Generate search criteria
GCriteria = cboSearchField.Value & ” LIKE ‘*” & txtSearchString & “*'”

‘Filter frmCustomers based on search criteria
Form_frmInventory.RecordSource = “select * from Inventory where ” & GCriteria
Form_frmInventory.Caption = “Inventory (” & cboSearchField.Value & ” contains ‘*” & txtSearchString & “*’)”

‘Close frmSearch
DoCmd.Close acForm, “frmSearch”

MsgBox “Your search results are currently being displayed.”

End If

End Sub

This discussion is locked

All Comments