Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

vba declaring public variables

Forum home » Delegate support and help forum » Microsoft Access Training and help » VBA declaring Public variables for use with forms -question for

VBA declaring Public variables for use with forms -question for

ResolvedVersion 2007

VBA declaring Public variables for use with forms -question for

Hi,
Please can you tell me how I can use Public variables in Access VBA, if I'm working with forms, and giving the variables their values in the form modules.

I've tried declaring the variable in the form modules and in the standard modules. But if the variable gets its value from the form controls and I try to use it in the other modules, it results in a message that the variable is not defined.

I have also experienced this working with forms and with ActiveX controls in Excel.

I have a work-around in Excel, but it would be good to know how to make the Public dimensioning work properly in Access.

RE: VBA declaring Public variables for use with forms -question

Hi Kathy, thanks for your query. The trick is to declare the public variable in a standard module rather than one of the form modules:

http://bytes.com/topic/access/answers/726791-using-global-variables-access-vb-form-modules

Try setting the variable up, then loading it with a value from form 1 and passing it to a control of form 2. Let me know if you encounter any problems with this.

Hope this helps,

Anthony

Access tip:

Run with the total

Often when creating reports with lists of transactions it can be useful to have a column which totals the transactions as the report progresses.

Using the Sum function gives the total for the whole group, not a running total.



Access provides an easy method of achieving a running total.



Click on the text box containing the data you wish to contain the running total.
Select the Data tab
Click in the Running sum option
Click the down arrow to view three options

View all Access hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.11 secs.