Syntax Error Missing Operator (1 Viewer)

jackh113

New member
Local time
Yesterday, 23:20
Joined
Sep 7, 2015
Messages
9
I am attempting to perform a Dlookup to populate an unbound control with the following command:

Me.txtad_Ship.Value = DLookup("[ad_Ship]", "[Tanks]", "[Job_ID] = " & Me.Job_ID)

For some of the records, I get an error message of "Syntax error (missing operator) in query experssion '[Job_ID] ='."

The crazy part that I don't get is that this command works for most of the records in the same form and the field [Job_ID] contains the correct ID#. I've also checked the table and it contains the appropriate value. I've also tried fetching the field with a sql Select statement with the same results.

I just don't get it. Why does it work on most records but not a select few? Any help would be greatly appreciated!!
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:20
Joined
May 7, 2009
Messages
19,247
Me.txtad_Ship.Value = DLookup("[ad_Ship]", "[Tanks]", "[Job_ID] = " & Nz(Me.Job_ID,0))
 

jackh113

New member
Local time
Yesterday, 23:20
Joined
Sep 7, 2015
Messages
9
Thank you for the replay.

While this would avoid the error, it would defeat my purpose as I still wouldn't fetch the value. The field [Job_ID] contains a value. I can see it. For some reason it doesn't pull into the expression for some records.
 

plog

Banishment Pending
Local time
Yesterday, 23:20
Joined
May 11, 2011
Messages
11,647
In the datasource of the form, what data type is Job_ID? In Tanks, what is the data type of Job_ID?
 

jackh113

New member
Local time
Yesterday, 23:20
Joined
Sep 7, 2015
Messages
9
Tanks is a table. The [Job_ID] is an Autonumber, Long Interger.

The datasource for the form is a query. Sorry, but don't know how to check the datatype in a query?
 

plog

Banishment Pending
Local time
Yesterday, 23:20
Joined
May 11, 2011
Messages
11,647
In a query you have to see how the cell justifies. Do the values align to the right or left when you run the query?

Sounds like they may be treated like text and you might have a non-numeric value apearing in Job_ID in the query. Can you sort Job_ID in the query Ascending and tell me what the first value is? The sort descending and tell me what the first value is.
 

jackh113

New member
Local time
Yesterday, 23:20
Joined
Sep 7, 2015
Messages
9
Everything is right justified in the query. This indicates numeric, correct?

Sorted ascending, the first value is 1.
Sorted descending, the last value is 1620.

Looks like the data type is numeric in both the table and query, correct?
 

plog

Banishment Pending
Local time
Yesterday, 23:20
Joined
May 11, 2011
Messages
11,647
Correct to both questions. I don't know what to tell you.

My gut tells me has something to do with a specific value of Job_ID. Find the value causing the error and research that value. Sorry I can't help more than that.
 

jackh113

New member
Local time
Yesterday, 23:20
Joined
Sep 7, 2015
Messages
9
That's my thought too but wasn't really sure where to start with it. It only does it with select records. Just wasn't sure where to start looking. I have the same expression in another Form that seems to be working fine. May force one of the offending records to appear in that Form and see what happens.

Thanks for your help.
 

Users who are viewing this thread

Top Bottom