A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

IIf in a report based on select query -- problem w/parameters



 
 
Thread Tools Display Modes
  #1  
Old March 25th, 2010, 01:44 PM posted to microsoft.public.access.reports
AGD
external usenet poster
 
Posts: 1
Default IIf in a report based on select query -- problem w/parameters

I have a report based on a select query. I've added a column in the report
to add information into the report based on whether or not two values within
the query are equal. The following code is in the unbound text box of my
report (created using expression builder).

=IIf(MG8!Cust_First_Order_Date_Time=MG8!OrdFlow_Ac tual_End,"1","0")

When trying to run the report I get the "Enter Parameter Value" window
requesting a parameter of MG8. Entering any or no parameter returns my
report with "1" in all rows (which is not correct based on review of data).
Here's what I've tried/done:
1. variations on the code's syntax but to no avail. (ie.
=IIf(([MG8]![Cust_First_Order_Date_Time]=[MG8]![OrdFlow_Actual_End],"1","0")

2. "masking" the field name within the query (ie. FO: Cust_First_Order_Date)
to get rid of possible "Date" confusion

3. text box in report is uniquely titled to avoid conflict

Here's what I'd like:

A. The reason it's not working
B. Help in writing the correct formula

Thanks in advance

  #2  
Old March 25th, 2010, 02:22 PM posted to microsoft.public.access.reports
ghetto_banjo
external usenet poster
 
Posts: 325
Default IIf in a report based on select query -- problem w/parameters

The reason it's not working, is because the report doesn't see any
fields called MG8 in it's local scope, hence it asks for its value as
parameter.

if MG8 is a query, is it the record source of the report? if so, they
you can just exclude it altogether, because the report will be able to
"see" those Cust_First_Order_Date_Time and OrdFlow_Actual_End fields.
You can verify which fields you can use in the report by viewing the
Field List in the View Menu.


if MG8 is a query that is not part of the report's recordsource, you
would need to use a DLookup function to get the values for those 2
fields.


if MG8 is the name of a form, then you need to change the syntax to:
Forms!MG8.Cust_First_Order_Date_Time



  #3  
Old March 25th, 2010, 02:26 PM posted to microsoft.public.access.reports
Allen Browne
external usenet poster
 
Posts: 11,706
Default IIf in a report based on select query -- problem w/parameters

Suggestions:

1. Omit the MG8!
Unless your query returns multiple fields with the same name, you don't need
to (and shouldn't) use the table name in your report.

2. Due to the way Access fetches data for a report, you may need to include
text boxes for Cust_First_Order_Date_Time and OrdFlow_Actual_End. Hide them
if you wish.

3. If you want numeric values (not text values), omit the quotes, i.e.:
=IIf([Cust_First_Order_Date_Time] = [OrdFlow_Actual_End], 1, 0)

4. Set the Format property of this text box to General Number (or some
numeric format), to ensure Access understands the data correctly.

5. If the date/time fields contain a time value (not just a date), they may
not be equal even if they look like they are (due to the way Access handles
fractions of a day.)

6. This all assumes that the query returns these actual fields.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"AGD" wrote in message
...
I have a report based on a select query. I've added a column in the
report
to add information into the report based on whether or not two values
within
the query are equal. The following code is in the unbound text box of my
report (created using expression builder).

=IIf(MG8!Cust_First_Order_Date_Time=MG8!OrdFlow_Ac tual_End,"1","0")

When trying to run the report I get the "Enter Parameter Value" window
requesting a parameter of MG8. Entering any or no parameter returns my
report with "1" in all rows (which is not correct based on review of
data).
Here's what I've tried/done:
1. variations on the code's syntax but to no avail. (ie.
=IIf(([MG8]![Cust_First_Order_Date_Time]=[MG8]![OrdFlow_Actual_End],"1","0")

2. "masking" the field name within the query (ie. FO:
Cust_First_Order_Date)
to get rid of possible "Date" confusion

3. text box in report is uniquely titled to avoid conflict

Here's what I'd like:

A. The reason it's not working
B. Help in writing the correct formula

Thanks in advance

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:47 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.