Open Form Code

  • Thread starter ladybug via AccessMonster.com
  • Start date
L

ladybug via AccessMonster.com

I am trying to make up my own security. So far I have been given help as you
will see below. I just have one more part that I need help on.
I have an unbound form called frm_login. This form has two unbound fields
called txt_login and txt_pw. I then have this code in a command button:

If IsNull(Forms!frm_login!txt_login) Then
MsgBox "Login is blank. Please enter login id.", vbCritical, "Login
Error"
Else
If IsNull(Forms!frm_login!txt_pw) Then
MsgBox "Password is blank. Please enter password.", vbCritical,
"Password Error"
Else
DoCmd.OpenForm "frm_auth"
If Forms!frm_auth!txt_authorized = 0 Then
MsgBox "The Login or Password you entered is not valid.
Please try again.", vbCritical, "Invalid User"
DoCmd.Close acForm, "frm_auth", acSavePrompt
DoCmd.Close acForm, "frm_login", acSavePrompt
DoCmd.OpenForm "frm_login"
Else
' myLogin = Forms!frm_auth!txt_login
' myRole = Forms!frm_auth!txt_role
DoCmd.Close acForm, "frm_auth", acSavePrompt
DoCmd.Close acForm, "frm_login", acSavePrompt
DoCmd.OpenForm "Switchboard"
End If

I have each login assigned a role. Multiple logins can have the same role.
Depending on the role assigned, will determine what command buttons are
available on the Switchboard. Examples of the roles are "QC" and "DE." What
code can I use to do this and where do I put it?
 
G

George Nicholson

Don't know enough about Switchboards to answer your question but:
DoCmd.Close acForm, "frm_auth", acSavePrompt
acSavePrompt prompts the user if they want to save any changes *to form
design* for that form. Its not likely, but it is possible that could include
password entries. Doubtful you would ever want that, so use acSaveNo
instead.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top