Access variable from form and module?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have VBA code on forms and VBA code in modules - how do I make a variable
that they can both access? (Or how do I pass infomation between the two?)

I want to have a module that has an open database function that I can reuse
on different forms. (i.e save me copy pasting database open each time) and
then return a variable - I can do this in c++, how do I do it in VBA?

Many thanks in advance
 
You need to declare the variable as public on an ordinary module, e.g. type

Public str As String

at the top of a module in your project. This is then available throughout
the project.
 
Back
Top