Passing Variable

TKnight

Registered User.
Local time
Today, 03:46
Joined
Jan 28, 2003
Messages
181
Hi I've set up a global variable "Action" using a module to track whether a user has clicked on a button on a form that i'm using as a message box.
I put "Dim Action As Boolean" in the declerations and defined it as False in a Public Sub.

The sub contains a Do While Action = False statement which works but I can't get a button on the form to change the variable to True and therefore break the loop.

In the forms module I have a button with the onclick event
Public Sub MyButton_Click()
Action = False
End Sub

But when you click the button it doesn't break the loop in the other module. Access would have thrown up an unidentified variable error if Action wasn't defined so I guess the variable is going to the class module it just isn't returning. Can anyone help, thanks, Tom.

P.S. Sorry I know there is a lot of stuff about passing variables on the site but I couldn't pick what i needed out of them! :o
 
Firsly, you don't need to specifically set the boolean to False (unless resetting it) as False is a newly dimensioned boolean's default value.

Secondly, how's about you show the code for your loop as you are saying that that is where the problem is but haven't given any info in order to help.
 
I've always been told off "Scolded even" for using global variables. I think its something to do with them getting corupted. So if you can store things in tables or possibly make a new property of your DB and store it in there.
 
TKnight said:
Do While Action = False statement which works but I can't get a button on the form to change the variable to True and therefore break the loop.

In the forms module I have a button with the onclick event
Public Sub MyButton_Click()
Action = False
End Sub


Might it help to set the boolean to TRUE when the button is clicked?

Regards

The Mailman
 
Sorry mate, didn't think that was important cause the loop is just...

Do While Action = False
Do Events
Loop

thanks, Tom.
 
Oops I meant True- I have that in my code just typo in the post!
 
Tony Hine said:
I've always been told off "Scolded even" for using global variables. I think its something to do with them getting corupted. So if you can store things in tables or possibly make a new property of your DB and store it in there.
You can use a hidden form to hold the variable
 

Users who are viewing this thread

Back
Top Bottom