View Full Version : If statement


DefDave
06-23-2008, 09:42 PM
Is there any way i can use an if statement in a report. What i want to do is say If column a = "yes" then textbox 1 = contents of column b Else textbox1 = contents of column c.

pbaldy
06-23-2008, 09:57 PM
Try this as the control source of textbox1:

=IIf(ColumnA = "Yes", ColumnB, ColumnC)

Replacing with the actual field names.

DefDave
06-24-2008, 05:41 AM
Thanks Paul - can you use ElseIf as well

pbaldy
06-24-2008, 07:57 AM
Yes, by nesting one IIf inside another:

=IIf(ColumnA = "Yes", ColumnB, IIf(ColumnA = "No", ColumnC, ColumnD))

Depending on what you're trying to do, it may be more practical to do it in VBA.

DefDave
06-24-2008, 09:42 PM
Thanks again Paul