Passing variables between userforms and/or normal procedures 
Author Message
 Passing variables between userforms and/or normal procedures

Hello, can somebody tell me something more
about the subject
I know how to pas variables from one procedure to
another. But how to do this with userforms (possible ?)

for instance:
How can I get the variable when i'm working in
my userform, or is it lost ?

sub start_myform(status_anyThing)
userform1.show
end sub



Tue, 23 Jan 2001 03:00:00 GMT  
 Passing variables between userforms and/or normal procedures
Hi

The only way 'I know of doing it is by declaring the variables globally.

Sorry, pal

Tron Walseth

Quote:

>Hello, can somebody tell me something more
>about the subject
>I know how to pas variables from one procedure to
>another. But how to do this with userforms (possible ?)

>for instance:
>How can I get the variable when i'm working in
>my userform, or is it lost ?

>sub start_myform(status_anyThing)
>userform1.show
>end sub




Tue, 23 Jan 2001 03:00:00 GMT  
 Passing variables between userforms and/or normal procedures
Here's a workaround. Make a call to a non-Private sub
in the UserForm's code module, passing the variable to
that sub. Then, in the called sub, tell the form to show itself.

Here's an example.

In your module:
        Sub TheCallingSub()
            Call UserForm1.ShowMe("I'm being passed over!")
        End Sub

In the UserForm (I plonked a label on it):
        Sub ShowMe(sPassedIn As String)
            Me.Label1.Caption = sPassedIn
            Me.Show
        End Sub

Once the ShowMe sub has got hold of the variable,
you can make it visible to all routines in the UserForm's
code by saving it to a variable Private to the form.



Quote:
> I know how to pas variables from one procedure to
> another. But how to do this with userforms (possible ?)
> for instance:
> How can I get the variable when i'm working in
> my userform, or is it lost ?

> sub start_myform(status_anyThing)
> userform1.show
> end sub



Tue, 23 Jan 2001 03:00:00 GMT  
 Passing variables between userforms and/or normal procedures


Quote:
>Hello, can somebody tell me something more
>about the subject
>I know how to pas variables from one procedure to
>another. But how to do this with userforms (possible ?)

>for instance:
>How can I get the variable when i'm working in
>my userform, or is it lost ?

>sub start_myform(status_anyThing)
>userform1.show
>end sub


You can pass a string to the form or its controls with the Tag proprty.

sub start_myform
        userform1.Tag = "Some_Status"
        userform1.show
end sub

Then when the userform1 is open use Me.Tag
--
Cliff Griffiths



Tue, 23 Jan 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Pass variable from procedure to procedure

2. Passing Texbox/combobox values to a macro, calling a stored procedure and passing these variables

3. Passing variables or arrays to userforms

4. Passing Variable Values between XLS and XLA Procedures

5. Passing User Form variable value to other procedures

6. Passing variable contents to form initiallization procedure

7. Passing an object variable to a procedure

8. How do I pass the value of a variable from one procedure to another

9. Run a SQL Stored Procedure in Access passing no variables

10. Passing Form Variables to Stored Procedure


 
Powered by phpBB® Forum Software © phpBB Group