Keep getting a run-time error 3075 missing operator

anoble1

New member
Local time
Today, 13:37
Joined
May 10, 2010
Messages
6
I have a report I am trying to limit down. I keep getting this error.
Code:
Run-time error '3075':
Syntax error (missing operator) in query expression ' and (Exercise = Barbell Squat)'.
Here is some of my code. What am I missing?

Code:
Dim whereCond As String
Forms!frmReports!cmdExercise.SetFocus
Exercise = Forms!frmReports!cmdExercise.Text

Forms!frmReports!cmdCategory.SetFocus
Category = Forms!frmReports!cmdCategory.Text
If Category <> "" Then
    whereCond = whereCond & " and (Category = " & Forms!frmReports!cmdCategory.value & ")"
End If

'Apply the Exercise filter is there is one.
If Exercise <> "" Then
    whereCond = whereCond & " and (Exercise = " & Forms!frmReports!cmdExercise.value & ")"
End If

'Open the report
DoCmd.OpenReport "rptFitNotesSummary", acViewPreview, , whereCond
 
When comparing strings you have to make them strings. That means enclosing them in single quotes:

whereCond = whereCond & " and (Exercise = '" & Forms!frmReports!cmdExercise.value & "')"

Its probably hard to see, but the above has single quotes in it that will allow it to work.
 
you are missing single quotation marks

Code:
 whereCond = whereCond & " and (Exercise = [COLOR=red]'[/COLOR]" & Forms!frmReports!cmdExercise.value & "[COLOR=red]'[/COLOR])"
Note quotation marks are only required for strings (text or memo type fields)

See plog beat me to it...
 
Accesslikeanyothercodeisveryliteralsospacesareusedtoseparatethingsandsospacesinnamesconfuseitunlessyoutellitthattheyhangtogetherbyusingquotes.Capisce?

( Or else see the explanations above by the other scribblers) :D
 

Users who are viewing this thread

Back
Top Bottom