UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Missing Operator, Access 2016    
 
   
JAchord
post Aug 22 2019, 08:58 AM
Post#1



Posts: 147
Joined: 11-July 14



Can someone please tell me what operator I am missing in this syntax "[Document_Description]like'*" & Me.DrawingWildcardtxt.Value & "*'" & "And '[drawing_class]='" & Me.DrawingClasscbx.Value I have tried moving quotations and different combinations for 30 minutes. Need some fresh eyes on it. Thanks for the education in advance.
Go to the top of the page
 
MadPiet
post Aug 22 2019, 09:02 AM
Post#2



Posts: 3,367
Joined: 27-February 09



"[Document_Description] like '*" & Me.DrawingWildcardtxt.Value & "*'" & " And '[drawing_class]='" & Me.DrawingClasscbx.Value

You need to make sure you're adding spaces. If you're trying to run a dynamic SQL statement, you gotta make sure it'll at least parse. if you create the query and assign it to a string variable

strSQL = "[Document_Description] like '*" & Me.DrawingWildcardtxt.Value & "*'" & " And '[drawing_class]='" & Me.DrawingClasscbx.Value & "'"

you can use Debug.Print strSQL and then copy the result to a query and run it.
Go to the top of the page
 
dale.fye
post Aug 22 2019, 09:04 AM
Post#3



Posts: 161
Joined: 28-March 18
From: Virginia


I'm assuming this is in a SQL string you are trying to build?
CODE
[Document_Description]like'*" & Me.DrawingWildcardtxt.Value & "*'" & "And '[drawing_class]='" & Me.DrawingClasscbx.Value

There are a couple of issues with this, as posted.

1. You need a space before the first Like
2. You need to close the quote around the value of me.DrawingClasscbx.Value
CODE
[Document_Description] like'*" & Me.DrawingWildcardtxt.Value & "*'" & "And '[drawing_class]='" & Me.DrawingClasscbx.Value & "'"

This assumes, of course that both DrawingWildcardtxtand DrawingClasscbx values are strings.

--------------------
Dale Fye
Microsoft Access MVP 2013-2016
Developing Solutions, LLC
Go to the top of the page
 
JAchord
post Aug 22 2019, 10:19 AM
Post#4



Posts: 147
Joined: 11-July 14



Well i tried to implement your suggestions but it is still giving me the error looking at the syntax in the error message (see attached screenshot) it looks like it should parse but no luck. I added a temp variable to make sure drawing class is a string.

Here is my current full code in case something else is causing the issue. I have the error handling disabled right now for debugging.

CODE
If IsNull(Me.DrawingWildcardtxt.Value) Then MsgBox "This will not work unless you enter a wildcard value first!"
        DoCmd.Hourglass False

    If IsNull(Me.DrawingClasscbx.Value) Then
    DoCmd.OpenForm "DrawingsFRM", , , "[Document_Description]like'*" & Me.DrawingWildcardtxt.Value & "*'"
    Forms.DrawingsFRM.DrawingNOtxt.Value = Me.DrawingWildcardtxt.Value
    Else
        
        If IsNull(Me.DrawingClasscbx.Value) And IsNull(Me.DrawingWildcardtxt.Value) Then

        Else
            Dim drawingclass As String
            Dim DrawingwhereasCriteria As String
            drawingclass = Me.DrawingClasscbx.Value
            DrawingwhereasCriteria = "[Document_Description] like '*" & Me.DrawingWildcardtxt.Value & "*'" & "And '[drawing_class]='" & drawingclass & "'"
            Debug.Print DrawingwhereasCriteria
            DoCmd.OpenForm "DrawingsFRM", , , DrawingwhereasCriteria
            Forms.DrawingsFRM.DrawingNOtxt.Value = Me.DrawingWildcardtxt.Value
        End If
    End If

Attached File(s)
Attached File  Capture.JPG ( 20.33K )Number of downloads: 0
 
Go to the top of the page
 
RJD
post Aug 22 2019, 10:38 AM
Post#5


UtterAccess VIP
Posts: 10,156
Joined: 25-October 10
From: Gulf South USA


Hi: Looks like you have an extra single-quote before [drawing_class] ...

DrawingwhereasCriteria = "[Document_Description] like '*" & Me.DrawingWildcardtxt.Value & "*'" & "And '[drawing_class]='" & drawingclass & "'"

Take that out - and I would also add a space before the And as well ...

DrawingwhereasCriteria = "[Document_Description] like '*" & Me.DrawingWildcardtxt.Value & "*'" & " And [drawing_class]='" & drawingclass & "'"

See if that gets you further along ...

HTH
Joe

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 
JAchord
post Aug 22 2019, 11:56 AM
Post#6



Posts: 147
Joined: 11-July 14



Thanks for furthering my education everyone that has it working. I tried the space before the "and" and tried removing the ' but I never tried both at the same time I guess.
Go to the top of the page
 
RJD
post Aug 22 2019, 12:03 PM
Post#7


UtterAccess VIP
Posts: 10,156
Joined: 25-October 10
From: Gulf South USA


thumbup.gif

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    14th December 2019 - 11:33 AM