Missing Operator '3075'

pikoy

Registered User.
Local time
Today, 14:28
Joined
Dec 23, 2009
Messages
65
Any help is appreciated.

Its basically a filtered report issue: Cant seem to find my mistake - Getting the Runtime 3075 syntax error.... in 'True AND [ID] = New Construction'

See below for the code:
Code:
Private Sub Preview_Click()
Dim strWhere As String
strWhere = "True" 'retrieve if no other' criteria are entered
If Not IsNull(Me!Category) Then
strWhere = strWhere & " AND [ID] = " & Me!Category
End If
DoCmd.OpenReport "Issues by Status", acViewPreview, , strWhere
End Sub

thank you...
 
Change this:

strWhere = strWhere & " AND [ID] = " & Me!Category

to this

strWhere = strWhere & " AND [ID] = " & Chr(34) & Me!Category & Chr(34)
 
I forgot to ask - do you have a lookup defined at table level on the ID field or is the ID field text - storing values like New Construction?
 
I forgot to ask - do you have a lookup defined at table level on the ID field or is the ID field text - storing values like New Construction?


Thanks for the reply Bob.

The ID field is text - i was wondering about that too.

the - & " just added the & to the error statement with the same error response.
 
The other thing is that I notice you have TRUE being returned and concatenated in without reference to a field. Why? That makes no sense and it won't work.
 
The other thing is that I notice you have TRUE being returned and concatenated in without reference to a field. Why? That makes no sense and it won't work.


Exactly... and i cant figure out why... and where its coming from.

so i redid the code to this ( see below ) which does the same thing
Code:
Private Sub Preview_Click()
Dim stDocName As String
stDocName = Me.Category
If Me.Category <> "" Then
[COLOR=red]DoCmd.OpenReport "Issues by Status", acViewPreview, , "Category = "
[/COLOR]Me.Category.Value = """"
Else
DoCmd.OpenReport "Issues by Status", acViewPreview
End If
End Sub

still getting the 3075 but this time to concat only states (Missing Operator... 'Category =' )

Btw, red font highlighted on debug
 
I think it can get about as simple as ...
Code:
Private Sub Preview_Click()
   Dim var As Variant
   If Me.Category <> "" Then var = "ID = '" & Me.Category & "'"
   DoCmd.OpenReport "Report1", acViewPreview, , var
End Sub
 
Thank you All... been looking at it and just figured out.

two words - string variable.

lagbolt - yup yours will work too. it has the same string variable requirement. but already solved it - it was right under my nose.

Thank you all again.
 

Users who are viewing this thread

Back
Top Bottom