Passing a variable from Object1 to a module in Object2

mba1942

Registered User.
Local time
Yesterday, 18:22
Joined
Apr 5, 2012
Messages
16
I have a generic log-in form object that I want to use to to grant access to a number of desired 'edit data' events which are called via 'buttons' from a MasterForm object. Some of the MasterForm event buttons do not require password access and some do.

Due to the nature of the app, the password is hard coded into the frmLogIn object vba code. If the password is correct, then I want pass a TRUE/FALSE value [PswdOK] back to the calling event VBA and then open (or not) the relevant 'editing' form object.

I can't seem to get the [PswdOK] value to pass from the frmLogIn object back to the VBA code in the calling event. I've tried to define the [PswdOK] variable as a Public variable and then modify it within the Private frmLogin VBA code but I guess I don't know how to do it correctly.

There's probably an easier way to do this.

Any suggestions would be welcome.

I'm sure you can tell I'm fairly new to this... MBA
 
assuming

[PswdOK] variable as a Public variable

is in your module this should work.

The alternative is to have a public function in your module along the following lines.

Code:
Public Function PasswordOK(UserInput as String) as Boolean
    PasswordOK=Replace(UserInput,"'","''")=HardcodedPassword
End Function

You probably don't need the Replace, but it helps stop SQL injection
 

Users who are viewing this thread

Back
Top Bottom