Automating/ Verifying data entry in a form

T

Tayo

I have a table shown below

UserID FName LName Pw
1A FN1 LN1 FN1LN1
2A FN2 LN2 FN2LN2
3A FN3 LN3 FN3LN3
4A FN4 LN4 FN4LN4

I now have a form with 4 textboxes named

txtUserID txtFName
txtPW txtLName


My Questions:
1. How would I set the controls so that when a user typed in his username in
the txtUserID textbox and his password in the txtPW textbox, the application
will check for the correctness of the entries from the table and if they
corresponds, it will automatically fill-in the txtFName and the txtLName
field with the corresponding first name and last name of that UserID

2. How would I make sure that a particular UserID that has been entered is
marked in the database so that the user cannot enter the same UserID & PW
again on another system?

I will really appreciate it if anybody can explain these answers to me so
that I can know the flow and why each step or procedure is necessary.

I am still a novice in MS Access
Thanks a lot.
 
B

bhicks11 via AccessMonster.com

You can use the DLOOKUP function to auto populate the required fields. You
can add an additional field to verify if the user is already open - Toggle it
open/closed.

Bonnie
http://www.dataplus-svc.com
 
T

Tayo

Hi Bonnie,

Thanks a lot for your answer but I need a solution that I can do by myself.
It will help me in knowing MS Access better.

Tayo
 
B

bhicks11 via AccessMonster.com

Tayo, that's a good idea. I thought I was suggesting a solution you can do
yourself.

Bonnie
http://www.dataplus-svc.com
Hi Bonnie,

Thanks a lot for your answer but I need a solution that I can do by myself.
It will help me in knowing MS Access better.

Tayo
You can use the DLOOKUP function to auto populate the required fields. You
can add an additional field to verify if the user is already open - Toggle it
[quoted text clipped - 32 lines]
 
A

arrkle

Item 1: Here is fairly simple way to do it:

Private Sub txtUserID_AfterUpdate()
GetInfo
End Sub

Private Sub txtPW_AfterUpdate()
GetInfo
End Sub

Private Sub GetInfo()
Dim result1 As Variant, result2 As Variant

If (Len(txtUserID) > 0 And Len(txtPW) > 0) Then
result1 = DLookup("FName","USER","UserID = '" & txtUserID & "' And Pw =
'" & txtPW & "'")
result2 = DLookup("LName","USER","UserID = '" & txtUserID & "'" And Pw =
'" & txtPW & "'")
If Not IsNull(result1) Then txtFName = result1
If Not IsNull(result2) Then txtLName = result2
End If
End Sub

If your table name is not "USER" then replace "USER" with the name of the
appropriate table.
That example could be made a little more rigorous by (among other things)
presenting users with a Message Box if no matching record is found.

Item 2: Assuming that "another system" uses the same form in the same
database, you might try adding a Boolean field to the "USER" table. It would
indicate whether or not the user is allowed to proceed.
 
T

Tayo

Hi Arrkle,

Thanks for your reply but I am having problem with the quotes... am I
suppose to use double quotes/ single quotes throughout or do I need to mix
it? Please help.

Tayo
 

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