I know I am missing something simple here... but I cannot figure it out. The below code is not disabling the button:
Forms!FrmMain.BtnAdmin.Enabled = False
What am I doing wrong?!
I know I am missing something simple here... but I cannot figure it out. The below code is not disabling the button:
Forms!FrmMain.BtnAdmin.Enabled = False
What am I doing wrong?!
Without knowing anything else about the database there are 2 possibilties:
1. Typo. You have mispelled the name of the form or button.
2. Event. The placement of the code is not occurring when you want it to.
What is the exact name of the form and button?
Where did you place the VB code?
Also, if the command to disable the button is on the same form as the button then you should be able to just type me.BtnAdmin.Enabled = False .
*****
Ok I just made a quick form and button, named the button BtnAdmin and in the OnLoad event of the form used me.BtnAdmin.Enabled = False and it did work.
Last edited by michaeljohnh; 10-05-2010 at 01:16 PM. Reason: additional comments
1. VB is recognizing the form and button name (Changed case of character and VB corrected).
2. I am placing the code after:
DoCmd.OpenForm "FrmMain"
DoCmd.Close acForm, "FrmLogOn"
The button name is "BtnAdmin"
In the OnLoad event of FrmMain enter the following:
me.BtnAdmin.Enabled = False
Sorry, I should have clarified that this code is working through multiple cases. Each case disables different buttons on the FrmMain form based on user rights in the FrmLogOn form.
Case 1
DoCmd.OpenForm "frmMain"
DoCmd.Close acForm, "frmLogOn"
Case 2
DoCmd.OpenForm "frmMain"
DoCmd.Close acForm, "frmLogOn"
etc...
So if the VB code is on FrmLogOn and the code to disable the button follows the code to close FrmLogOn, then the reason for it not working seems to be that the code to disable the button isnt getting executed because the form it is on has been closed.
Moving the code has had no effect
The only other option I can think of is moving the entire Select/Case sub to the OnLoad event of the frmMain. Since the login info is being stored somewhere, it should be easy enough to check it during the OnLoad event rather than on the frmLogOn. With one database I made, I left the login form open but repositioned it behind the other forms so I could pull from the username field for exactly this type of check. Although that was a very low security db, so logging in was more to apply user preferences than a security measure.
If that doesnt work, someone else will hopefully be able to help you, I will be heading home soon.
I like the idea of leaving the login form open and will try that. Thanks!