Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Value to Access Report 2

Status
Not open for further replies.

bblekfeld

Programmer
Mar 9, 2004
49
US
The Below report asks for a value each time it is run. (A transaction ID) How do I pass that value to it programatically as opposed to typing it in in the input box Access provides?

Private Sub Command907_Click()
DoCmd.OutputTo acReport, "CreditCardReceipt", "HTML _(*.html)", "c:\testoutput", False, "", 0


End Sub
 
I'm assuming that the prompt is requesting a legitimate value that is being used to configure your report at run time.

(a)One way to do what you want, is to include a control on the form which invokes the report. Then in the underlying query / sql which is tied to the report (via the recordsource), you simply refer to this control.

Assuming the control on the form is called YourControl, and the form is called frmYourForm, then your reference to it would be:

Forms!frmYourForm!YourControl

(b) Another way to pick up a value without including it (directly) in the user interface is to use the DLookup function on a table where you store and maintain parameter values (eg. say a tax rate).

(c) A third way might be to define some public variables, and then to write some small functions to retrieve these values from queries or other objects. First two methods usually preferable though this has its uses as well.



Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
for example a)
you are saying that I would then put

Forms!frmYourForm!YourControl

in the criteria for the underlying query instead of a having it prompt me to "Enter Transaction ID" and that should do the trick.

From what I understand, that's what you seem to be suggesting. I tried that.

The reference I actually used is:

[Forms]![New Form]![Transaction Subform]![Trans_ID]

Is there something I need to do differently?
 
If you're using a subform, then the syntax is slightly different:

Try:

[Forms]![New Form]![Transaction Subform].Form![Trans_ID]


Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
Steve101: I thought my app was dead when my company suddenly migrated from 2000 to 2003. Your form reference saved me!
 
cwfrizzell,

Glad to be of assistance.


Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top