Help with Iif Statement

E

e.winterod

In a form reading from a query, i have 4 unbound fields.

[New Pages Published]
[Pages Deleted]
[Updated Pages]

For each field I want it to sum the [# of Pages After] for the associated
Action.

Example: Sum the [#of Pages After] if [Action] = "New" and display in the
[New Pages Published] unbound field.

I am not sure if an Iif statement will work in the Countrol Source of if
there is a better solution.

I am still a beginner at building databases/writing code.

Any help is greatly appreciated :)

Thanks!!
 
K

KARL DEWEY

'Sum' means to total multiple records. Normally a form displays a single
record at a time. You can use 'DSum' to total more than one record while
displaying only one. The 'IFs' will be the criteria in the DSum.
 
J

John Spencer

In a report, you could use the following as the source of ac control.
=Sum(IIF([Action]="New",[# of Pages After],0))
That will work assuming that [# of Pages After] is a field (column).

In a form, you will need to use something more like the following
DSum("[# of Pages After]","[Name of the Table or Query]","[Action]=""New""")

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
E

e.winterod

Thank you John!!

John Spencer said:
In a report, you could use the following as the source of ac control.
=Sum(IIF([Action]="New",[# of Pages After],0))
That will work assuming that [# of Pages After] is a field (column).

In a form, you will need to use something more like the following
DSum("[# of Pages After]","[Name of the Table or Query]","[Action]=""New""")

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

e.winterod said:
In a form reading from a query, i have 4 unbound fields.

[New Pages Published]
[Pages Deleted]
[Updated Pages]

For each field I want it to sum the [# of Pages After] for the associated
Action.

Example: Sum the [#of Pages After] if [Action] = "New" and display in the
[New Pages Published] unbound field.

I am not sure if an Iif statement will work in the Countrol Source of if
there is a better solution.

I am still a beginner at building databases/writing code.

Any help is greatly appreciated :)

Thanks!!
.
 
E

e.winterod

Thank you!!

I am using 2007 with a split form does that make a difference in being able
to use a total?

KARL DEWEY said:
'Sum' means to total multiple records. Normally a form displays a single
record at a time. You can use 'DSum' to total more than one record while
displaying only one. The 'IFs' will be the criteria in the DSum.

--
Build a little, test a little.


e.winterod said:
In a form reading from a query, i have 4 unbound fields.

[New Pages Published]
[Pages Deleted]
[Updated Pages]

For each field I want it to sum the [# of Pages After] for the associated
Action.

Example: Sum the [#of Pages After] if [Action] = "New" and display in the
[New Pages Published] unbound field.

I am not sure if an Iif statement will work in the Countrol Source of if
there is a better solution.

I am still a beginner at building databases/writing code.

Any help is greatly appreciated :)

Thanks!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top