Variables in reports

  • Thread starter Thread starter Vegard Villmones
  • Start date Start date
V

Vegard Villmones

Hi!

I'm kind of a newbie with Access and reports therein. I want to store
some variables in a report. That is, I open a report from a form, then
I want to print certain values (to the printer) from this form after
previewing it in the report, so it's convenient to close the form
before previewing the report - because it blocks the view, but then
when I want to print it the values from the form is gone, like
Forms("myForm").TodaysDate. So I wonder how do I store values into the
report? I've tried storing them to variables, textboxes and the lots,
no success, the unleashed book helps me as much as a kick in the face
on this.

regards

Vegard
 
Vegard,

Declare a global variable in the declarations section of any general
module:
Public myVar as ...

From the form, store your values in global variables (form Close event):
Private Sub Form_Close()
myVar = me.ControlName (change ControlName to the actual name of the
control on the form)
End Sub

Then in the same (or any other general) module make a function to return
each variable:
Function Get_myVar()
Get_myVar = myVar
End Function

Now, with the value assigned to myVar before you close the form, you can use
function Get_myVar anywhere in the report, just like any Access built-in
function, to retrieve the value in myVar.

HTH,
Nikos
 
Back
Top