login form

W

Wes Derhak

Hi

I need help with a custom login screen. The following tables and fields are
what I have to work with as I'm new to MS Access;

Table Field

Staff Info SN (Staff Number) (Primary Key)
Name
Int
First

Account Info SN
UserID
Password


I have created four forms "Login", "Add Staff", "Wardroom" and "Account
Info". The Add Staff & Account Info are for inputting new staff only. What I
need to do is have the "Login" command button verify the userid and password
from the "Account Info" and if successful it will then open a form called
Wardroom and to that staff's record

The Wardroom form has several subforms which allows them to input
information only into their records

Any help is appreciate!
Wes
 
C

Carl Rapson

Wes Derhak said:
Hi

I need help with a custom login screen. The following tables and fields
are
what I have to work with as I'm new to MS Access;

Table Field

Staff Info SN (Staff Number) (Primary Key)
Name
Int
First

Account Info SN
UserID
Password


I have created four forms "Login", "Add Staff", "Wardroom" and "Account
Info". The Add Staff & Account Info are for inputting new staff only. What
I
need to do is have the "Login" command button verify the userid and
password
from the "Account Info" and if successful it will then open a form called
Wardroom and to that staff's record

The Wardroom form has several subforms which allows them to input
information only into their records

Any help is appreciate!
Wes

First of all, will any employee ever have more than one UserID and Password?
If not, there's no reason to store those fields in a separate table; put
them in the Staff Info table.

In the Click event of the Login command button, fetch the SN based on the
entered UserID and Password:

lngSN = Nz(DLookUp("SN","[Staff Info]","[UserID]='" & txtUserID & "' AND
Password='" & txtPassword & "'"),0)

Note the single quotes around the UserID and Password values I'm assuming
they are text values. If you need to, you can do more granular checking by
opening a recordset using the UserID only (DAO example):

Dim rs as DAO.Recordset
Set rs = CurrentDB.OpenRecordSet("SELECT SN, Password FROM [Staff Info]
WHERE UserID='" & txtUserID & "'")

If no record is found, the UserID is invalid. If a record is found, check
the Password field to make sure it matches what was entered. If the password
is OK, you now have the SN for opening the Wardroom form:

lngSN = rs![SN]

You can now position Wardroom to the staff's record by passing the SN in the
WhereCondition parameter of OpenForm:

DoCmd.OpenForm "Wardroom",,,"[SN]=" & lngSN

This assumes that the Wardroom form is based on a table or query that
contains the SN as one of its fields. Be sure to use your own table, field,
and control names in place of the dummy ones I've used. You say you're new
to Access, so you may want to read up on recordsets, DAO vs. ADO, and
writing VBA code.

Hopefully this will give you a starting point. The best way to learn is by
doing, and asking questions when needed.

Carl Rapson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top