Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2008

Tip: Looking for answers? Try searching our database.

How do I make a function in vba?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hanski - 22 May 2008 11:58 GMT
hi.

I have Private sub name1() and Private sub name2() in my vba.

I have Dim X as interger and I give value to X in Private sub name1().

I would like to use X also in Private sub name2(). Do I have to make a
function or how can I use this X-value I gave in Private sub name1()
also in Private sub name2()?

t hanski
Wolfgang Kais - 22 May 2008 12:08 GMT
Hello "hanski".

"hanski"wrote:
> I have Private sub name1() and Private sub name2() in my vba.
>
[quoted text clipped - 3 lines]
> a function or how can I use this X-value I gave in Private sub name1()
> also in Private sub name2()?

The problem seems to be the "scope" of the variable x. If you declared
x inside of name1, name2 can't access that variable. If both procedures
were defined inside the same module, you could declare x at the module
level (at the top of the module, beneath the Option line(s) and before
any sub or function. You can use "Dim" or "Private" to declare x.
If name1 and name2 were defined in different modules, you will have to
declare x as a global variable in a standard module, using
Public x As Integer

Signature

Regards,
Wolfgang

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.