Login-form?

Ranniks

Registered User.
Local time
Today, 12:48
Joined
Feb 8, 2012
Messages
12
How do I get this form code (I found on the internet):

Username.SetFocus
If Username = "staff1" And Password = "staff1" Then
MsgBox "Access Granted", vbInformation, "CD Shop"
MsgBox "Welcome", vbInformation, "CD Shop"
DoCmd.Close
DoCmd.OpenForm "F_Switchboard"
ElseIf Username = "staff2" and Password = "staff2" Then
MsgBox "Access Granted", vbinformation, "CD Shop"
MsgBox "Welcome", vbinformation, "CD Shop"
DoCmd.Close
DoCmd.OPenForm "F_Switchboard"
ElseIf Username = "manager1" and Password = "manager1" Then
MsgBox "Welcome, Manager", vbinformation, "Manager Area"
MsgBox "Please Exercise Caution When Altering Back End", vbinformation, "Manager Area"
DoCmd.Close
DoCmd.OPenForm "F_Switchboard_Manager"
Else
MsgBox "Please re-enter your Username and Password."
End If

To instead of just checking if the username is manager1, to check the username and password directly from a table?

For school I need to make a login form, one for admin, one for customer and one for a visitor. I invision this: Login screen, login button, and a button called 'I'm a guest'.

I would need to make 3 switchboards, one for admin, one for customer and one for visitor.

Could someone give me some help or adjust the code I found please?
 
its a wee bit more complex than the code youve just posted
 
You need to describe how your security will work because that will dictate the level of detail you need in the tables and the type of code you'll need for verification. I'll describe what I use in one of my applications.
Table with users. Contains demographic info plus UserID and Password.
Table with Functions. These are the "functions" that the application "knows".
Table with UserFunctions. This table maps the User to the Functions he may perform.

In the Login Form, you collect the UserID and Password and validate it against tblUsers.

In every other Form that is not generally open, you need code at one or more points to verify that the logged in user has permission to perform this function. Each Form "knows" what function it needs to look for depending on what the user is attempting to do. So for example, if the user is trying to update a subscriber record, the Form knows that the function it needs to look for is "Update" so it uses DCount to see if the logged in user has a Function record with the value of "Update". If you break out updates into a more granular level, then you'll need more entries in the Function table and different forms will use a different value when looking to see if the user can update this particular form. So one will look for "UpdateDemo" and another might be "UpdateFinancial".

Don't go crazy with breaking out a zillion functions. Use as high a level as you can. If you have lots of users, you might even want to create group profiles so you can assign the same permissions to multiple people without having to do it in detail. this is the way Windows security works.

Thx!

I'm actually unfamiliar with sql coding in access.....I don't really know how to start/what to do. Do you know a tutorial?

Basically my system is (school assignment): a store where you can buy music numbers.

I have a members table, group tab, music tab, etc etc. Basically I don't have a user tab with password and all, so I need to make that. I'll have to link the members table with the users table to distinguish the members, because we have three kind of groups: admins, members and guests. The last one shouldn't exist in the users tab.

If there is a tutorial out there, please link me to it.
 

Users who are viewing this thread

Back
Top Bottom