LOG ON FORM AS STARTUP

J

JUAN

Hello,
I would like to have a LOGON USER FORM as my startup Form.
Form has following:
USER_ID
PASSWORD
O.K BUTTON AND CANCEL BUTTON.

I created a table called Employee with fields:
USER_ID (NAME)
PASSWORD(TEST1) Sample .
I created a blank form and added a combo box from the
Employees table to get USER_ID. I then added another text
box to put Password.
I want to be able to select User_ID from box and type in
password and when I click O.K, To open another form. Am I
doing this righ and how can I do the Event procedure if
user = password, open form else WRONG USERID/PASSWORD.
ANY HELP would be great,
thanks,
juan
 
V

Van T. Dinh

Something like:

****Untested code****
Private Sub cmdOK_Click()

If DCount("*", "Employees", "[USER_ID] = '" & Me.txtUSER_ID & _
"' AND [PASSWORD] = '" Me.txtPASSWORD & "'") > 0 Then
' Assumption: both USER_ID and PASSWORD Field are of Text type!
' Matched. Proceed
DoCmd.OpenForm "OtherForm"
DoCmd.Cclose acForm, Me.Name, acSaveNo

Else
' USER_ID & PASSWORD not matched
MsgBox "Wrong!"
End If
****
(replace Field & Control names with appropriate names from your set-up.)

HTH
Van T. Dinh
MVP (Access)
 
T

tina

-----Original Message-----
Hello,
I would like to have a LOGON USER FORM as my startup Form.
Form has following:
USER_ID
PASSWORD
O.K BUTTON AND CANCEL BUTTON.

I created a table called Employee with fields:
USER_ID (NAME)
PASSWORD(TEST1) Sample .
I created a blank form and added a combo box from the
Employees table to get USER_ID. I then added another text
box to put Password.
I want to be able to select User_ID from box and type in
password and when I click O.K, To open another form. Am I
doing this righ and how can I do the Event procedure if
user = password, open form else WRONG USERID/PASSWORD.
ANY HELP would be great,
thanks,
juan
.
here's an easy solution. your user_id and password are in
the same table. and the combo box on the form is populated
from the same table. so add the password to the combo box
as a second column (set the column width to 0" so the
column will be invisible to the user, to preserve password
security). then it's easy to check the employee's
password, by setting the following code on the OK button's
click event:

Private Sub Command0_Click()

If Me!TextBox <> Me!ComboBox.Column(1) Then
MsgBox "The password is not correct."
Else
DoCmd.OpenForm "FormName"
End If

End Sub

just put in the correct control names, and the message you
want to display. fyi, "Column(1)" refers to that second,
invisible column you added to the combo box.
 

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