enabled a cmdButton based upon another form

mghdb

Registered User.
Local time
Today, 14:12
Joined
Aug 3, 2000
Messages
26
can anyone help me with my dilemna? i have a form that prompts the user to enter a password to modify records, if the correct password is enter, the "modify" button is enabled. i'm having trouble referencing that button which is on another form. please help? thanks in advance.
 
If you have a form, frmPassword, which has a command button, cmdOk, that the user has to click on to verify the password and then allow rights as applicable, you can put this line of code in the cmdOK control's OcClick event procedure:

Private Sub cmdOK_OnClick()
' Assume that PasswordVerified is the result of you testing the password entered
docmd.openform "Other Form",,,,,,(PasswordVerified = True)
End Sub

For the form "Other Form", with the Modify Button control, cmdModify, put this line in the form_Load procedure

Private Sub Form_Load()
me.cmdModify.Enabled = me.openargs
End sub

What you are doing here is passing a parameter to the form with the modify button. if the parameter is true then you enable the modify button otherwise disable it.

Another situation would be if the other form were open already.
You would reference the control as

Forms![Other Form]![cmdModify].Enabled = PasswordVerified


ntp

[This message has been edited by ntp (edited 01-18-2001).]
 
thank you for your quick reply. i'll try out the code
 

Users who are viewing this thread

Back
Top Bottom