thesaurusrex
Registered User.
- Local time
- Today, 16:12
- Joined
- Aug 2, 2005
- Messages
- 14
I'm trying to implement multi-field search of a single table. Here is what I have now:
I get an error (run-time 3075) every time I run this. The error is:
and following the WHERE it says tblentry.contitu;'. for example if I have chosen the constituencyid for searching. Or tblentry.st;' if I chose statusid.....it's always the last six characters cut off. If I enter data into both constituencyidsearch (in this case 4) and statusidsearch, I get the following after WHERE: tblentry.constituencyid=4tblentry.st;'.
I've looked at other examples of this type of search and can't figure out what is causing my syntax issues. Any help would be appreciated.
Code:
Private Sub cmdSearch_Click()
Dim strFind As String, strWhere As String
If Len(Me.entryidsearch & vbNullString) > 0 Then
strWhere = strWhere & "tblEntry.entryid=" & Me.entryidsearch
End If
If Len(Me.divisionidsearch & vbNullString) > 0 Then
strWhere = strWhere & "tblEntry.divisionid=" & Me.divisionidsearch
End If
If Len(Me.constituencyidsearch & vbNullString) > 0 Then
strWhere = strWhere & "tblentry.constituencyid=" & Me.constituencyidsearch
End If
If Len(Me.statusidsearch & vbNullString) > 0 Then
strWhere = strWhere & "tblentry.statusid=" & Me.statusidsearch
End If
If Len(Me.summarysearch & vbNullString) > 0 Then
strWhere = strWhere & "tblEntry.summary LIKE '%" & Me.summarysearch & "%' AND "
End If
If Len(Me.keywordsearch & vbNullString) > 0 Then
strWhere = strWhere & "tblentry.keywordflag = true"
End If
If Len(Me.facultysearch & vbNullString) > 0 Then
strWhere = strWhere & "tblentry.facultyflag = true"
End If
If Len(strWhere) > 0 Then
strWhere = " WHERE " & Left(strWhere, Len(strWhere) - 8)
strFind = "SELECT tblEntry.entryid, tblentry.divisionid, tblentry.constituencyid, tblentry.statusid, " & _
"tblentry.dateopened, tblentry.notes, tblentry.action, tblentry.summary " & _
"FROM tblentry " & strWhere & ";"
Dim stdocname As String
stdocname = "frmdocumentation"
DoCmd.OpenForm stdocname, , , strFind
Else
MsgBox "No matching records found"
End If
End Sub
I get an error (run-time 3075) every time I run this. The error is:
Code:
Syntax error. in query expression 'SELECT tblEntry.entryid,
tblentry.divisionid, tblentry.constituencyid, tblentry.statusid,
tblentry.dateopened, tblentry.notes, tblentry.action,
tblentry.summary FROM tblentry WHERE *(see below)
I've looked at other examples of this type of search and can't figure out what is causing my syntax issues. Any help would be appreciated.