Here: faq181-5497 FancyPrairie provides what I consider beautiful search code. I have already used parts of this in one db with positive results. Now, I am using parts again in second db, but I cannot get the combo box process to work. The text and date fields process correctly, it is only with the combo box that I get the error.
Here is my info:
Error Code and Text:
Run-time error '3075': Syntax error (missing operator) in query expression '(qryTrain.StaffID In(7,'.
Debug.Print strWhere (with StaffID 7 selected from the list and no other search criteria input):
(qryTrain.StaffID In (7,
Tag for control (cboSStaff):
Where=qryTrain.StaffID,Number,=;
Relevant Code from module:
I have come up with three ideas that may have caused this error, but when I implemented them as 'fixes' to the code, the syntax error disappeared but other errors were created.
I would rather not go into them unless asked, as I doubt they would be helpful.
If anyone can help it will be much appreciated! Thanks!
Here is my info:
Error Code and Text:
Run-time error '3075': Syntax error (missing operator) in query expression '(qryTrain.StaffID In(7,'.
Debug.Print strWhere (with StaffID 7 selected from the list and no other search criteria input):
(qryTrain.StaffID In (7,
Tag for control (cboSStaff):
Where=qryTrain.StaffID,Number,=;
Relevant Code from module:
Code:
BuildComboBox:
'*******************************************
'* Determine Operator (=, >, Like, etc.) *
'*******************************************
strAndOr = vbNullString
If (Len(strOperator) > 0) Then
If (strOperator = "<>") Then strAndOr = " AND " Else strAndOr = " OR "
End If
If (Len(strOperator) = 0) Or (strOperator = "=") Then
strWhere = strWhere & strAnd & " (" & strFieldName & " In ("
strSuffix = ", "
Else
strWhere = strWhere & strAnd & " (" & strFieldName & " " & strOperator & " "
strSuffix = ") " & strAndOr
End If
If (Len(strFieldValue) = 0) Then strFieldValue = ctl.Column(ctl.BoundColumn - 1)
strWhere = strWhere & strFieldType & strFieldValue & strFieldType & strSuffix
Debug.Print strWhere
strAnd = " AND "
Return
I have come up with three ideas that may have caused this error, but when I implemented them as 'fixes' to the code, the syntax error disappeared but other errors were created.
I would rather not go into them unless asked, as I doubt they would be helpful.
If anyone can help it will be much appreciated! Thanks!