Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Users logging on directed to the correct forms 1

Status
Not open for further replies.

MichelleButler

IS-IT--Management
Apr 5, 2002
73
GB
I have an access database that is used by a large orgnisation. There are different levels of access to the database. The database has been split so the users are running the correct form, but they are all connecting to the same table. I have users logging into the database now, but want I would like to be able to do is direct them to the correct form. i.e., I have a login table that contains username, password, and access level. When they logon I have two dialog boxes, username and password, when they press enter, this directs them to the main form. I would like to be able to "Write some code that checks the username, and access level in the table, i.e., admin and then this would direct them to the Admin form" and so on. Any suggestions!!!!!!!!!!!
 
Take a look at the DoCmd.OpenForm method and the If instruction.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
hi, not the most elegant solution but the simplest and quickest to implement - add a column to your username/ password table to include the name of the form you want them to go to. when they enter their username use the dlookup function to get the name of the next form, i.e.
Code:
docmd.openform dlookup("FORM_NAME", _
"LU_USERS", "USERNAME = " & me.txtusername)
where form_name is the column name [containing form names], lu_users is the table and txtusername is the name of the from control containing their logon name.

If you wanted something smarter normalise the table so that you have a LU_START_FORM with columns for access level and form to open. Create a view between LU_USERS and LU_START_FORM joined on access level and dlookup your view instead. There are faster methods than dlookup but they are more complicated to implement.

Hope this helps (since you disliked my prev suggestions so!), Jamie
 
Thank you Jamie for your reply. The information was very useful, unfortunately I can see this working but I am struggling to adapt the above coding into my code as I have already a Dlookup when trying to find the password. If I insert the above coding it already tells me that the form has been closed. The previous login script I am trying to adapt is If you could help me, this would be very much appreciated.

Michelle
 
Hi MichelleButler,

I Have Same Organized DB So Try This, On Enter Click:

Set Rsc = CurrentDb.OpenRecordset("Select * From YorTableName Where [UserNameField] = '" & UserNameTextBox & "'" & " And [PasswordField] = '" & PasswordTextBox & "'")
If Rsc.RecordCount = 0 Then
MsgBox "Sorry You Have No Permisson, Try Again", vbOKOnly, ""
End If

Good Luck


" Åä Çááå íÍÈ ÅÐÇ Úãá ÃÍÏßã ÚãáÇ Ãä íÊÞäå "
 
Hi, does you code look something like this, open next form then close current? I notice on the code your adapting it closes current then opens next which is probably causing the problem...
Code:
'Close logon form and open splash screen

DoCmd.Openform DLookup("FORM_NAME", _
"LU_USERS", "USERNAME = " & me.txtusername)

DoCmd.Close acForm, "frmLogon", acSaveNo

Hope this helps, Jamie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top