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

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Missing Operator    
 
   
DaveLA
post Apr 11 2012, 05:28 PM
Post #1

UtterAccess Addict
Posts: 257



I have used any number of vba statements as a filter in the WHERE clause like the one below. The usual cause of the missing operator for me was a missing "Quote" sign. I can't see what the cause of the error here. There is no text field:

"([PartID] = " & dblPartID & " AND [Size] IsNull) OR ([PartID] = " & dblPartID & " AND [Size] IsEmpty)"

[PartID] Type is Double; [Size] Type is integer.

(Bet the answer is probably obvious)

DaveLA
Go to the top of the page
 
+
Alan_G
post Apr 11 2012, 05:39 PM
Post #2

Utterly Yorkshire and Forum/Wiki Editor
Posts: 15,886
From: Devon UK



Hi

Is this as part of a WHERE clause in an SQL string in VBA ?

Anyhooo, I'd imagine the error is because of the way you're using the IsEmpty() function - you haven't passed a variable to it. It would be more like

CODE
"([PartID] = " & dblPartID & " AND [Size] IsNull) OR ([PartID] = " & dblPartID & " AND IsEmpty([Size])"


but I don't really understand why you're doubling up the WHERE clause by saying [Size] IsNull and then IsEmpty([Size]) ? Couldn't you just say something like

CODE
"([PartID] = " & dblPartID & " AND [Size] Is Null)"
Go to the top of the page
 
+
DaveLA
post Apr 11 2012, 06:05 PM
Post #3

UtterAccess Addict
Posts: 257



Yes it is part of the Where clause in an SQL vba statement. I have tried both with and without the "IsEmpty", as well as "Is Empty" vs. "IsEmpty"

Avery simple statement, should work.

DaveLA
Go to the top of the page
 
+
Alan_G
post Apr 11 2012, 06:26 PM
Post #4

Utterly Yorkshire and Forum/Wiki Editor
Posts: 15,886
From: Devon UK



Hi

Easiest way to spot errors is to use the Immediate Window. If you asign your SQL statement to a string variable along the lines of

strSQL = "SELECT blah blah blah....."

you can put

Debug.Print strSQL

immediately after the full SQL is constructed. The full SQL with the variables evaluated will then be in the Immediate Window (Ctl + G) where you should be able to spot whatever's causing the problem
Go to the top of the page
 
+
the_captain_slog
post Apr 12 2012, 02:43 AM
Post #5

UtterAccess Veteran
Posts: 305
From: England - UK A small island north of France



you could try

CODE
"([PartID] = " & dblPartID & " AND " & [Size] & "IsNull) OR ([PartID] = " & dblPartID & " AND IsEmpty(" & [Size] & ")"


you seem to be passing [size] as text
Go to the top of the page
 
+
arnelgp
post Apr 12 2012, 03:31 AM
Post #6

UtterAccess Ruler
Posts: 1,090



"([PartID] = " & dblPartID & " AND (Isnull([Size]) OR [Size]=0))"
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 25th May 2013 - 07:06 AM