I have a table with various fields, a number of fields relate to the same data type, i.e. Language1, Language2, Language3, Language4, - I want to be able to search all of the fields for e.g. Spanish.
I currently use a combo list which is unbound, but without the user having to manually select each Language field to search in, i want the search to look in all of the Language fields automatically by only selecting, say "Language".
Below is the code used to search the fields....
Expand|Select|Wrap|Line Numbers
- 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 frm_Report based on search criteria
- Form_frm_ReportCam.RecordSource = "select * from providers_cam where " & GCriteria
- Form_frm_ReportCam.Caption = "providers_cam (" & cboSearchField.Value & " contains '*" & txtSearchString & "*')"
- DoCmd.OpenForm "frm_ReportCam"
- 'Close frm_SearchBoxCam
- DoCmd.Close acForm, "frm_SearchBoxCam"
- End If
- End Sub
cheers.