Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Access variable from form and module?

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unload A Form based on a Variable in my Module [email protected] Excel Programming 4 May 2nd 07 11:11 PM
How to Set a Variable in Another Module? Steve Drenker[_4_] Excel Programming 1 March 17th 06 06:28 PM
Variable in more than one module Nick M[_3_] Excel Programming 2 November 8th 05 07:20 PM
Is it possible to open the VBA form with a link in a sheet and to pass variable from a cell to the VBA form? Daniel[_14_] Excel Programming 1 August 29th 04 01:20 PM
Variable from a sheet module in a class module in XL XP hglamy[_2_] Excel Programming 2 October 14th 03 05:48 PM


All times are GMT +1. The time now is 10:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"