Using MS Access/Report If Then Statement


QUESTION: I am trying to write a if statement on a report field that is sourced by a query.  I am trying to say if the Transaction Type field = Intercompany give me All FS Item #s fro the FS Item field on the query that are between 0000010000 and 0000059999, otherwise give me all the FS Item numbers from the FS item number field in the query.

=IIf([Transaction Type]="Intercompany",[FS Item] Between "0000010000" And "0000059999",[FS Item])

ANSWER: I would do it differently. I would add a field that returned True or False as to whether the FS Item was in the range. Then I would set the criteria to:

Transaction Type = "Intercompany" AND Betw = True OR Transaction Type <> "Intercompany"

Hope this helps,

---------- FOLLOW-UP ----------


Not sure I understand you answer completely?  Create a new field in my query first for the True of False, and then in the report type this criteria?  How will this bring me back the "FS Item" field number?

Queries do not have fields. They have columns that are either linked to a field or contain an expression.

But yes you create the column in your query. You can set the criteria in the query or as part of the OpenReport method.

Hope this helps,
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA

Using MS Access

All Answers

Answers by Expert:

Ask Experts




I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.


I've been designing databases for over 25 years working with dBase, FoxPro, Approach and Access.

Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

Brooklyn College BA

©2017 All rights reserved.