pass on value from private to public sub

mafhobb

Registered User.
Local time
Today, 09:49
Joined
Feb 28, 2006
Messages
1,249
Hello.

This is probably pretty simple...

I have several private subs in a single form's code and one public sub. This public sub is called by several private subs.

I need to be able to pass on a value from each private sub (when used) to the public sub.

Remember, it is all in the same form.

Ideas?

Thanks

mafhobb
 
Just make the Public sub accept parameters.. then you can pass values when you call them.. something like...
Code:
Private Sub Form_Current()
:
Call yourPublicFunction("someValue")
:
End Sub

Public Sub yourPublicFunction(var As String)
:
'your code
:
End Sub
It would be best to place the Public Sub inside a Module.. That way it can be called by any Form in the application.
 
Or make the variable Public within the form module.
 
Under the First line where you have Option Compare Database or Option Explicit the next line just declare the variables that you wish to use in may subs/functions.. Something like..
Code:
Option Compare Database

[COLOR=Green]' Variables that used across all functions atleast a maximum of 2 [/COLOR] 

Dim sHostName As String
Dim sUserName As String

Private Sub Form_Current()
:
[COLOR=Green]'Your code[/COLOR]
:
 

Users who are viewing this thread

Back
Top Bottom