ThomasLafferty
Instructor
I have a disabled textbox control that I would like to enable via a command button and a password form. As the available features in the database expand, I would like to be able to use the same password form over and over and just pass expected values via a function so that I don't have to write a password routine for every feature. The problem is that my variables expire when I close the password form. Here's what I have so far:
I probably don't really need two functions. What I am attempting to do is use a global boolean variable which is initialized to false: boolEnableFeature.
The functions should allow me toggle that variable between true and false based on user input in the password form. Once everything works, I can lock down the forms so that design view is not allowed, and lock down the module where my public function(s) are stored so that they require password to view.
What am I doing wrong? (other than spaghetti code...)![[smile] [smile] [smile]](/data/assets/smilies/smile.gif)
Born once die twice; born twice die once.
Code:
Public Sub btn_EnableTextBoxZoom_Click()
Call InitPassword("frmWeighDetail", "z00m", False)
If boolenablefeature = True Then
Me.OriginalVals.Enabled = True
Else
Me.OriginalVals.Enabled = False
End If
End Sub
Public Static Function InitPassword(StrObjIdentity, StrRequiredPassword, boolenablefeature As Boolean)
boolenablefeature = False
DoCmd.OpenForm "frmPassword"
End Function
Public Static Function CheckPassword(StrPassword As String)
If StrTypedPassword = StrRequiredPassword Then
boolenablefeature = True
Else
boolenablefeature = False
MsgBox "Invalid password", vbInformation, "Access Denied"
End If
End Function
I probably don't really need two functions. What I am attempting to do is use a global boolean variable which is initialized to false: boolEnableFeature.
The functions should allow me toggle that variable between true and false based on user input in the password form. Once everything works, I can lock down the forms so that design view is not allowed, and lock down the module where my public function(s) are stored so that they require password to view.
What am I doing wrong? (other than spaghetti code...)
![[smile] [smile] [smile]](/data/assets/smilies/smile.gif)
Born once die twice; born twice die once.