Discussion Locked

Access-Pass value from form to report

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am a just above "novice" status, but I do know some VB code. I just have never used Access and VB together and VB is rusty!

I need to take the value of the current record's OrderID and pull the report for only that OrderID. I want to do so bydeclaring a global variable and then pulling that variable into the report.

I would appreciate someone just copying a bit of code they have used for an example--including
1. code on the original form (what DIM statements, etc, and how to send that variable to the global,
2. the global code and, I guess, public procedure, and
3. the Report (or form--should not matter)code which brings the code into the report.

I have some that work with forms![frmSales]![OrderID] = Me![OrderID]

but others won't work even when both forms are left open.

Thanks!

4 replies

by richtee

A very simple way to run a report using the ?current record?s OrderID? from a form as the parameter for the report is to create an intermediary query and then have the report use this query as its control source.

The query (containing all the fields you need for the report) would have the value of the ?current record OrderID? from the report as its parameter.

A generic example of the parameter for the criteria for this field in the query would be: [Forms]![Form1]![Text0]

Just replace the name of the form and the control that your are referencing in the example.

Good Luck.

Rich

by skennedy10

Thanks. This method I figured out, also, from the examples I had (I am repairing a db created by someone else). I understand it better now, though.

I still would like an example of creating a global variable in code which works or ischanged from multiple forms.

This is getting me through this project, though, so thanks.
Susan

This discussion is closed to new replies.