Using Global Variable in Report

R

Rick

In a function I've declaired a variable as Public
strVendor as string
In this function strVendor is set to a value.

Within this function I open a report and in it's format
event I try to check the value of strVendor. I keep
getting a Variable Not Defined error. I'm pretty sure
defining the variable again in the report's code is not
the answer because that is resetting the variable to null.
I've done this before but can't remember how. What I'm I
forgetting?

Thanks.

Rick
 
D

Dirk Goldgar

Rick said:
In a function I've declaired a variable as Public
strVendor as string
In this function strVendor is set to a value.

Within this function I open a report and in it's format
event I try to check the value of strVendor. I keep
getting a Variable Not Defined error. I'm pretty sure
defining the variable again in the report's code is not
the answer because that is resetting the variable to null.
I've done this before but can't remember how. What I'm I
forgetting?

Don't declare the variable inside the function. Declare it at the
module level, outside of any procedure, in the Declarations section of a
standard module.
 
B

Bas Cost Budde

Rick said:
In a function I've declaired a variable as Public
strVendor as string
In this function strVendor is set to a value.

Within this function I open a report and in it's format
event I try to check the value of strVendor. I keep
getting a Variable Not Defined error. I'm pretty sure
defining the variable again in the report's code is not
the answer because that is resetting the variable to null.
I've done this before but can't remember how. What I'm I
forgetting?

Thanks.

Rick

The variable must be module level public; that is, the Public
declaration should be at the top of the module (and it must not be a Class).
 
B

Bas Cost Budde

Dirk said:
<g>

Hi, Bas! I noticed you're back. It's good to see you active in the
newsgroups again.
Yes, but I hope not to spend too much time duplexing answers ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top