Reputation: 167
I am trying to create a simple login form in access and it should take the user to their designated access database/form based on the user's login information, below is my code:
Private Sub Command6_Click()
Dim strpassword As String
Dim password As String
Dim userlevel As String
password = Me.Text0.Column(1)
userlevel = Me.Text0.Column(2)
strpassword = Me.Text4
If strpassword = password Then
If userlevel = "Admin" Then
GetObject ("C:\Users\accessdatabase.accdb")
DoCmd.OpenForm "Form"
Else
(open other forms)
End If
Else
MsgBox "Nope"
End If
End Sub
I know I am doing something wrong. I actually have no idea what to do after the userlevel check. I have searched some commands online but it didn't work. Anyhelp would be really appreciate
Thanks
Upvotes: 1
Views: 5508
Reputation: 153
I would declare the object as a variable:
Dim objAdb As Object
Set objAdb = CreateObject("Access.Application")
objAdb.OpenCurrentDatabase ("C:\Users\accessdatabase.accdb")
objAdb.DoCmd.OpenForm "Form"
regardless of your method, you need to point the docmd that you have to the other DB
Upvotes: 5