View Full Version : enabled a cmdButton based upon another form


mghdb
01-18-2001, 04:33 AM
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.

ntp
01-18-2001, 05:24 AM
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).]

mghdb
01-18-2001, 07:30 AM
thank you for your quick reply. i'll try out the code