View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Smallweed Smallweed is offline
external usenet poster
 
Posts: 133
Default Access variable from form and module?

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.

"parkin_m" wrote:

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

--
Thanks

Parkin_m