UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Switchboard After Login, Access 2016    
 
   
noobdba
post Jun 24 2019, 03:01 PM
Post#1



Posts: 19
Joined: 21-June 19



I created a main menu (switchboard) to show up when the db opens. After all the tables, queries, and reports, I created a login form. Is it possible to have the switchboard open after a successful login?
Go to the top of the page
 
theDBguy
post Jun 24 2019, 03:13 PM
Post#2


Access Wiki and Forums Moderator
Posts: 75,777
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Welcome to UtterAccess!
welcome2UA.gif

Of course! Once you have verified a successful login, you can open any form you want to display.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
noobdba
post Jun 24 2019, 03:25 PM
Post#3



Posts: 19
Joined: 21-June 19



Hello theDBguy

I'm unfortunately lacking in VBA. Which is why I found someone's code; which is below. All I added was the DoCmd.OpenForm "Main Menu" at the end of the sub. Would this work?

Private Sub cmd_login_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String

If Trim(Me.txt_username.Value & vbNullString) = vbNullString Then
MsgBox prompt:="Username should not be left blank.", buttons:=vbInformation, title:="Username Required"
Me.txt_username.SetFocus
Exit Sub
End If

If Trim(Me.txt_password.Value & vbNullString) = vbNullString Then
MsgBox prompt:="Password should not be left blank.", buttons:=vbInformation, title:="Password Required"
Me.txt_password.SetFocus
Exit Sub
End If

'query to check if login details are correct
strSQL = "SELECT FirstName FROM tbl_login WHERE Username = """ & Me.txt_username.Value & """ AND Password = """ & Me.txt_password.Value & """"

Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL)
If rst.EOF Then
MsgBox prompt:="Incorrect username/password. Try again.", buttons:=vbCritical, title:="Login Error"
Me.txt_username.SetFocus
Else
MsgBox prompt:="Hello, " & rst.Fields(0).Value & ".", buttons:=vbOKOnly, title:="Login Successful"
DoCmd.Close acForm, "frm_login", acSaveYes
End If

Set db = Nothing
Set rst = Nothing
DoCmd.OpenForm "Main Menu"
End Sub
Go to the top of the page
 
theDBguy
post Jun 24 2019, 03:33 PM
Post#4


Access Wiki and Forums Moderator
Posts: 75,777
Joined: 19-June 07
From: SunnySandyEggo


Hi. If the name of your Switchboard is "Main Menu," then I supposed it should work. What happened when you tried it?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
noobdba
post Jun 24 2019, 03:36 PM
Post#5



Posts: 19
Joined: 21-June 19



It worked! I needed another set of eyes before I used it. Thanks!
Go to the top of the page
 
theDBguy
post Jun 24 2019, 04:01 PM
Post#6


Access Wiki and Forums Moderator
Posts: 75,777
Joined: 19-June 07
From: SunnySandyEggo


Hi. Congratulations! Glad to hear you got it to work. Good luck with your project.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    23rd July 2019 - 07:14 AM