Tony Hungate
asked on
Issue pulling a user type from table at login
I have set up a simple login validation via this bit of VB
Now I find that I need to pull another value from the tblLogIn. I need to lookup the AcctType from tblLogIn and place it on my frmNavigation in a textbox named txtAcctType.
The navigation form is always open and would provide the mechanism for me to reach back and verify that the user that is currently logged in has access to different parts of the db and forms later.
Thanks in advance.
Dim LogonValid As Integer
LogonValid = Nz(DCount("*", "tblLogIn", "([UserName] = '" & Me("txtUserName") & "') and ([Password] = '" & Me("txtPassword") & "')"), 0)
If LogonValid > 0 Then
DoCmd.OpenForm "frmNavigation"
Forms!frmNavigation!txtUser = Me.txtUserName
Me.txtUserName = ""
Me.txtPassword = ""
Else
MsgBox "Invalid Login"
End If
End Sub
Now I find that I need to pull another value from the tblLogIn. I need to lookup the AcctType from tblLogIn and place it on my frmNavigation in a textbox named txtAcctType.
The navigation form is always open and would provide the mechanism for me to reach back and verify that the user that is currently logged in has access to different parts of the db and forms later.
Thanks in advance.
ASKER
I am not very good with syntax beyond the very basic, and the solution provided is throwing a syntax error on this line.
Thanks for the quick response.
Forms!frmNavigation!txtAcctType='" & accType & "'"
Thanks for the quick response.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
mbizup,
I have attempted to use utilize your solution. I have set the recordsoruce for frmNavigation to tblLogIn, and set the rowsource for both txtUser and txtAcctType to their respective fields within the table.
I am still getting a syntax error on my login forms login button click event, from the following line.
Thanks for your assistance.
~:TLH:~
I have attempted to use utilize your solution. I have set the recordsoruce for frmNavigation to tblLogIn, and set the rowsource for both txtUser and txtAcctType to their respective fields within the table.
I am still getting a syntax error on my login forms login button click event, from the following line.
DoCmd.OpenForm "frmNavigation",,, "UserName = '" & Me.txtUserName "'"
Thanks for your assistance.
~:TLH:~
What is the exact error message you are getting?
Ooops...
Try this (I missed an '&' at the end):
Try this (I missed an '&' at the end):
DoCmd.OpenForm "frmNavigation",,, "UserName = '" & Me.txtUserName & "'"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
capricorn1
That did it. Thanks for your help.
mbizup,
I will award you partial points at the final solution was a combination of works.
Thanks all.
That did it. Thanks for your help.
mbizup,
I will award you partial points at the final solution was a combination of works.
Thanks all.
t__hungate,
I'm not objecting to the point split - cap1 has also posted a working solution. but my post here should have resolved the error in my method: http:#a37364799
The point is, however, that in your application you should use one solution or the other (they are different methods). With a bound form, you dont need the code to put values in the boxes after opening the form.
I'm not objecting to the point split - cap1 has also posted a working solution. but my post here should have resolved the error in my method: http:#a37364799
The point is, however, that in your application you should use one solution or the other (they are different methods). With a bound form, you dont need the code to put values in the boxes after opening the form.
Dim LogonValid As Integer, accType as string
LogonValid = Nz(DCount("*", "tblLogIn", "([UserName] = '" & Me("txtUserName") & "') and ([Password] = '" & Me("txtPassword") & "')"), 0)
If LogonValid > 0 Then
accType= Nz(DLookup("AcctType", "tblLogIn", "([UserName] = '" & Me("txtUserName") & "') and ([Password] = '" & Me("txtPassword") & "')"), "")
DoCmd.OpenForm "frmNavigation"
Forms!frmNavigation!txtUse
Forms!frmNavigation!txtAcc
Me.txtUserName = ""
Me.txtPassword = ""
Else
MsgBox "Invalid Login"
End If
End Sub