Syntax Error Missing Operator (1 Viewer)

tmyers

Well-known member
Local time
Today, 10:27
Joined
Sep 8, 2020
Messages
1,090
I need another set of eyes to see what I am missing as I am unable to figure out why I am getting a syntax error on :

MultiCut: IIf(IsNull(DCount("CutLength","tblMultiConductorCut","TicketID = " & [Reports]![rptWireRoom]![TicketID]))=True, 0 ,DCount("CutLength","tblMultiConductorCut","TicketID =" & [Reports]![rptWireRoom]![TicketID]))

I am trying to count records based off "CutLength" using TicketID from my report (not form) and return 0 if there are no records so I do not get #ERROR in my control as I am doing multiple DCounts and doing some adding and multiplying. This is based in the reports control query and I do all the adding and such in the control on the report itself.
 

Ranman256

Well-known member
Local time
Today, 10:27
Joined
Apr 9, 2015
Messages
4,337
put IIF statements in the query, not the report.
then you can inspect the data returned.
 

Gasman

Enthusiastic Amateur
Local time
Today, 15:27
Joined
Sep 21, 2011
Messages
14,306
Split them up until they work, then reassemble.
 

tmyers

Well-known member
Local time
Today, 10:27
Joined
Sep 8, 2020
Messages
1,090
Is having a IIF statement in the reports record source query causing this? Is that what you mean?
 

plog

Banishment Pending
Local time
Today, 09:27
Joined
May 11, 2011
Messages
11,646
First 3 rules of Debugging: Simplify, Divide and Conquer.

First, DCount will not return NULL, so that makes your expressions way simpler--everything but one DCount goes away.

If that doesn't get rid of your syntax issue, strip out the criteria. Get something to work, even if its not exactly what you want. once you have a starting place you can easily figure out which part is the offending code. If your DCount works without criteria, you now know its your criteria. If it doesn't work without criteria you've either mistyped a field or table name.
 

tmyers

Well-known member
Local time
Today, 10:27
Joined
Sep 8, 2020
Messages
1,090
Understood. I will tear it apart and reassemble until it breaks again.
 

Gasman

Enthusiastic Amateur
Local time
Today, 15:27
Joined
Sep 21, 2011
Messages
14,306
I tend to put the criteria into a string variable for domain functions if not a single simple criteria.
Then I can debug.print them to see if I have the syntax correct.
The when correct, I can use them in the function.
Plus, if you cannot see the error, you can copy and paste here or eslewhere, so someone can point out the error.?

Whilst your code is an expression, you can still do the same thing, to test bit by bit.
 

Users who are viewing this thread

Top Bottom