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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If statement in reports

Status
Not open for further replies.

devagupt

Vendor
Oct 27, 2006
40
US
I have summed all "Actual production" in a report. I need to sum all " Packaged production " in a report. I have a check box "Inspect only " . "Packaged Production" is all the "Actual Production" minus the Actual production which have "Inspect Only" checked. How do i do this in a report? an IF statement?

Kindly help.
 
How do i integrate it with a check box? should i input this in the control source for Packaged production on my report?

= If [Inspect only] = Yes Then [Packaged units]= [Total units] -[Actual units]

Is the syntax ok?
 
sorry on my delay

i think there is an easy way

create a textbox for each record with this record source

=IIF([Inspect only] = Yes,[Packaged units]= [Total units] -[Actual units])

and in the report or page footer sum all of the text boxes that has this record source for example

=Sum([TextTotals])

assuming the textbox you added is named texttotals
 
You can't sum controls (text boxes) from one section of a report to another. You can sum an expression similar to this which will sum the Total-Actual where Inspection Only is true:

=Sum(Abs([Inspect only])*([Total units] -[Actual units]))


Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
did you try typing what i worte in a record source with the iif function why cant you do it because by me it works please let me know
 
IGPCS,
Sorry to be picky but, what works? Did you try your solution in a report?

You provided an IIf() function that contains only two arguments. A quick check of Help states:
IIf(expr, truepart, falsepart)

The IIf function syntax has these named arguments:

Part Description
expr Required. Expression you want to evaluate.
truepart Required. Value or expression returned if expr is True.
falsepart Required. Value or expression returned if expr is False.
Also, you seem to be attempting to assing a value with the truepart
[Packaged units]= [Total units] -[Actual units]
That will only evaluate to either true or false.

Also, you can't sum a control from the detail section in a group or report header or footer. If you attempt to sum a control, you will get a parameter prompt for [TextTotals].

Also, text boxes have Control Sources, not Record Sources.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
thanks i hope you got me on the record source but yes you need to enter a false part as well sorry if there was a missunderstanding

have a great week

= IIF ("Your in USA", "Have a happy holoween", " ")

IGPCS
New York
 
It worked guys. Thanks.I have other questions . I usually work on Access at work and therefore will ask you guys those questions tomorrow. Hope you guys can help.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top