Issue pulling a user type from table at login

I have set up a simple login validation via this bit of VB

Dim LogonValid As Integer
  
  LogonValid = Nz(DCount("*", "tblLogIn", "([UserName] = '" & Me("txtUserName") & "') and ([Password] = '" & Me("txtPassword") & "')"), 0)
  'Stop
If LogonValid > 0 Then
  DoCmd.OpenForm "frmNavigation"
  Forms!frmNavigation!txtUser = Me.txtUserName
  Me.txtUserName = ""
  Me.txtPassword = ""
 
  
Else
  MsgBox "Invalid Login"
End If

End Sub

Open in new window


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.
LVL 10
Tony HungateTechnical Writer/Trainer | CISSPAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

plummetCommented:
Hi, you should look at DLookup, eg

dim sAcctType as sstring

sAcctType=dlookup("AcctType", "tblLogin","([UserName] = '" & Me("txtUserName") & "') and ([Password] = '" & Me("txtPassword") & "')")
if isnull(sAcctType) then
 MsgBox "Invalid Login"
else
 ... go off and do something eg
  Forms!frmNavigation!txtAcctType=sAcctType
end if
0
mbizupCommented:
Is frmNavigation bound to anything (its recordsource property)?

If not, you could bind it to tblLogin, and have hidden textboxes to hold AcctType  and any other info that you need from tblLogin.

Like that, you could refer to these things from anywhere else in your database like this:

If Forms!frmNavigation.txtAcctType = "Admin" Then '<--- refers to a textbox on frmNavigation named txtAcctType
   'Etc

Open in new window

0
mbizupCommented:
Just a note, if you do what I suggested in my previous comment, you would have to open your navigation form filtered for the specific user like this:

  DoCmd.OpenForm "frmNavigation",,,"[UserName] = '" & Me("txtUserName") & "'"

Open in new window

0
Tony HungateTechnical Writer/Trainer | CISSPAuthor Commented:
Sorry all, I somehow posted this questions twice.

Please see this link for remainder of the solution.  Thank you everyone for your quick response.

http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_27516295.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tony HungateTechnical Writer/Trainer | CISSPAuthor Commented:
Duplicated Question.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.