Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with syntax error 2

Status
Not open for further replies.

rudolfelizabeth

Programmer
Jan 14, 2009
89
CW
access 2003
I am trying to get a sum between two dates input by the user, for the positive amounts in the price field .
I get a syntax error below the code

Positivesum: DSum("quantity*transactions!price","transactions"," and format([Transdate],'yyyymmdd') between format([Begindate],'yyyymmdd') and <= format([Enddate],'yyyymmdd') and Transactions!price >0")
 
You will never get = Null to work since Null is like an unknown. Also, you can't set a value in you IIf(). [Beginbal]=[BeginBalance] is going to return either 0 or -1

Duane
Hook'D on Access
MS Access MVP
 
Duane is exactly right. But it seems like you are trying to get this...

Code:
BeginBalForDisplay: Nz([Beginbal],[BeginBalance])

To test for null you would either use the ISnull fucntion or the criteria IS Null...

Another way to do the above...

Code:
IIF(Isnull([Beginbal], [BeginBalance],[Beginbal])


Criteria might look like...

Code:
Where [BeginBal] Is Null
 
I don't want this in the query, in the query I have

both the beginingbalance
and the beginbal
the query is bound to the report

what is the code for the report
control source

to evaluate that if in the query the beginbal is null
then use the beginingbalance instead if this is > null


 
=IIF(Isnull([Beginbal]), [BeginBalance],[Beginbal])
In the control source of the report does give me an error

when I run the report

 
What error? A hunch is that one of your control names is the same as one of the fields you are using in the expression.
 
box name aliasBeginbal

it just puts the word error on the report

code like above
=IIF(Isnull([Beginbal]), [BeginBalance],[Beginbal])

 
In design view, Select a control.

On the formatting (form/report) toolbar drop down the contol list and try to find beginbal or beginbalance. If you do select it so you know where it is. If it is not exactly equal to the field name, you need to give it a different name.
 
Lameid
Thank you very much

I had another textbox with beginbal
I changed it
everything is working ok

Thank Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top