Global variables

dowingc

Board Regular
Joined
Oct 27, 2002
Messages
77
Trying to get a variable on one form to work on another. I have one form set a value on a variable, then the user is to click a button which opens another form. Then I want to apply that variable in this new form. Unfortunately I cannot figure out how to do this in Access VBA. I have tried making a module with a line:

public vartype(cnumber) as integer

and then using 'cnumber' throughout the program, and this doesn't work. :x Please show me the light!

Thanks in advance.

Chris
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Maybe you should put this code in its own module rather than a form module. I don't work with Public variables too much, so I don't know the answer. Most of the Access users on this site are Beginner, Intermediate, or Semi-Advanced and only a few work with VBA. If there is no answer to your question, I'd go to

http://www.access-programmers.co.uk/

and look through their Archives (you can post a new topic, but be careful as they get a little testy about answering new posts that have already been explored :wink: ).

*I looked through their Archives and found this:

In order to create a Global Variable, substitute the Dim Keyword with Public. Make your Declaraion in the General Declarations section of a Module. And away you go...

But it sounds like you did that?!
 
Upvote 0

Forum statistics

Threads
1,221,513
Messages
6,160,242
Members
451,632
Latest member
purpleflower26

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top