T. T. T said:
I have built a report based on a parameter query. I have a field in
my report that is a calculation( Availiable Spend: Format([Gross
SqF]*2) ). Instead of multiplying by 2 I want to use a different
value each time I run the report. So, I would like to specify the
constant. Can I enter a parameter that asks for the constant in the
above calculation? If so, how? Thanks.
Well, the simplistic answer is: just do it:
Format([Gross SqF]*[Enter multiplier])
The problem of course is the lack of control: what if the user enters "two"?
Or misses the 5 key and hits T instead? Most experts use an unbound form to
solicit input from users and pass the values to reports, thus providing the
opportunity to validate the input before opening the report. If you select
that route, the steps would be:
- create a form in design view (without using the wizard and without
selecting a base table) - call it frmYourReportName
- place a textbox control on the form and call it txtMultiplier with a label
instructing the user to enter a number (no alpha characters).
- place a button on the form with the caption "Run Report"
- create an onclick event for the button in which you validate the entry in
the textbox and then use docmd.openreport to open the report
- amend the calculation above in the report to say:
Format([Gross SqF]*frmYourReportName!txtMultiplier)
An alternative to the above would be to create a VBA function in a module
that uses InputBox to get the input from the user, validates it and returns
the value (perhaps returning 1 if the input is not valid. If that is the
course you decide on, you would use this:
Format([Gross SqF]*YourFunctionName())