How launch proper form depending on user's login

SteveL13
SteveL13 used Ask the Experts™
on
Am working with an old Access database which utilizes Users and Groups Permissions.

Is there a way to make one of two forms open when the user logs in depending on that user's login?

I'm already using this code to determine the user:

If DBEngine.Workspaces(0).Users(CurrentUser).Name = "Shop" Then
blah, blah, blah
end if

If the user is "Shop" then I want a particular form to open.  If it's any other user then I want another particular form to open.

--Steve
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
If DBEngine.Workspaces(0).Users(CurrentUser).Name = "Shop" Then

    docmd.openform "form1"

else

       docmd.openform "form2"
end if

Author

Commented:
Where would this code go?  In the inopen event of form2?

(I'm not at my computer now or I would try it)
Top Expert 2016

Commented:
you can place the code in a click event of a button in your login form.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
The login form is the "canned" login form from MS using Users and Groups.  I'm not sure I have control over it, do I?
Top Expert 2016

Commented:
where is this code located

If DBEngine.Workspaces(0).Users(CurrentUser).Name = "Shop" Then
blah, blah, blah
end if

Author

Commented:
On a form that is launched from a dashboard "Main Menu" named frmMainMenu.  frmMainMenu is opened by default as determined by File/Options/Current Database/Display Form.
Top Expert 2016

Commented:
do you want to open either "form1" or "form2"  from frmMainMenu ?

Author

Commented:
That's not what should work.  The way I need it to work is to have either form1 OR form2 open depending on the user login.

If the user is "shop" then form2 should open.  That would be their Main Menu or dashboard.

If the user is any other than "shop" then form1 should open.  That would be their Main Menu or dashboard.
Top Expert 2016

Commented:
do you have a form that opens before the "Dashboard" is shown?

Author

Commented:
Yes...  frmMenuLauncher
Top Expert 2016

Commented:
Can you edit the form?

Author

Commented:
Yes.
Top Expert 2016
Commented:
then place the codes in the click event of a button in frmMenuLauncher

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial