PC Review


Reply
Thread Tools Rate Thread

Access variable from form and module?

 
 
=?Utf-8?B?cGFya2luX20=?=
Guest
Posts: n/a
 
      8th Aug 2007
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 With Quote
 
 
 
 
=?Utf-8?B?U21hbGx3ZWVk?=
Guest
Posts: n/a
 
      8th Aug 2007
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
referencing a variable from a form in a module Matthew Dyer Microsoft Excel Programming 2 7th Oct 2009 10:57 PM
Form name as a variable in a module E Microsoft Access VBA Modules 7 11th Sep 2008 05:18 PM
Variable in module to reference form Jordan Microsoft Access Form Coding 6 2nd Jul 2008 08:12 PM
Transfer Variable from Form to Module =?Utf-8?B?R2xlYW0=?= Microsoft Excel Programming 2 6th Sep 2007 05:54 AM
Passing Access.Form object to a class module variable =?Utf-8?B?U3JlZWRoYXI=?= Microsoft Access VBA Modules 3 31st Jan 2007 02:53 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:41 PM.