Open Admin Form after Login (1 Viewer)


Registered User
So the way the database works is once the database is opened the login window "frmlogin" appears (Picture 3). Once a member of staff matches their name and password they are direct to "Form1" which is a control window where the member of staff can access reports and apply for annual leave etc.. If Admin logs in using the sign in name Admin and matches the password, the user is directed to a different window called "frmPCSManager".

Currently if a member of staff logs in they are directed to the correct form "Form1" BUT if Admin logs in, it just stays on the login screen. If I exit the login screen it directs me to "frmPCSManager" which I want to access through pressing the Login button rather than exiting the login screen.

I've gone through the coding again Picture 1 & 2 and I can't understand why it's not directing me to "frmPCSManager" once the Login button is pressed in the similar fashion that members of staff can access "Form1" from pressing the login button.

Thanks for your input @Gasman



Enthusiastic Amateur
They appear to getting Form1 as it is already open.?
You are calling the login Form from that form.

If you put a breakpoint in Form1 where you check Trim(Me.txtHidden and see what that has, however you are opening the login form in acdialog mode and not closing it if admin, but do so if not admin?

Why isn't the login form your starting form.?
Seems a roundabout way to login in to me, even with my inexperience.?

If you indented the code correctly, this would be easier to spot.?
Plus it is easier to post a piece of code within code tags than it is posting pictures of code.?

FWIW the way I would have done it is have Login form as my start form. Then depending who the user is, open the next form/switchboard and close the login form.


When you say you go through the code line by line, is that in your head or using the debugger, to see exactly what does happen, not what yout think will happen?
Last edited:


error reading drive A:
Private Sub cmdLogin_Click()
	Dim strID As String
	strID = Dlookup("[EmployeeID]", "Employees", "[UserName]=" & _
		Chr(34) & Me.cboUser.Column(1) & Chr(34) & " And " & _
		"Password=" & Chr(34) & Me.txtPassword & Chr(34)) & ""
	If strID <> "" Then
		gEmployeeID = strID
		If cboUser.Column(1) = "Admin" Then
			Forms!Form1.txtHidden = "Admin"
			Forms!Form1!lblWelcome.Caption = "Welcome " & Me.cboUser.Column(1) & " " & Me.cboUser.Column(2)
		End If
		Docmd.Close acForm, Me.Name
		Msgbox "Invalid user or password. Please try again.", vbInformation + vbOkOnly
	End If
End Sub


Enthusiastic Amateur
How does that work?
I cannot see any difference to what you had, except for Arne indenting the code? :confused:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)