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!

Login from Query - Username to match timer minutes 1

Status
Not open for further replies.

nim180

IS-IT--Management
Aug 11, 2005
161
AU
I have a login form, when the user enters a username/password it opens the main database form and a small timer form, the timer form has 1 textbox which counts down from a certain time. I would like to do the following:

1. The login form is linked to tblLogin. The table has the fields username, password and minutes. There are certain minutes corresponding to each username, i.e 15 or 30 or 60 minutes. When the user logs in using a username/password i would like the corresponding minutes to be placed into the textbox of the timer form.

2. Also each username/password can only be used once, when the user logs in is there a way of locking that record or maybe even better would it be possible to maybe delete the username and password for that record without deleting the whole record?

Thanks,
Nim
 
It would help if we knew how far you'd got with this one because it would be a waste to go back too far.

If your login form is already looking up the username in a table and retrieving the password then the obvious move is to add a "minutes" field to the username table and get that value at the same time as you're getting the password.

As for the problem of locking the username/password after a single use, you could add a boolean field named "used" to the table of usernames and only allow login if its value is false. Set it true as soon as a user logs in and that will prevent the name being used again.

Geoff Franklin
 
Hey alvechurchdata,

Yes my login form is already looking up the username from the table and retrieving the password. I have the minutes field already in the table with the assigned minutes to each username and password. How would i go about getting the minutes corresponding to each username to be placed into the textbox of my timer form?

As for my second query ill give your method a shot tonight and get back to you.

Thanks,
Nim
 
This is the code behind my login page. I inserted a field called "Used" with a property of true/false, how would i implement this into my code to lock a username if it has been used before.

Code:
Dim lUserID As Long

    If Len(Nz(Me.Name1, "")) = 0 Then
        MsgBox "Enter your User Name"
        Me.Name1.SetFocus
        Exit Sub
    End If

    If Len(Nz(Me.Password1, "")) = 0 Then
        MsgBox "Enter your Password"
        Me.Password1.SetFocus
        Exit Sub
    End If
    
    lUserID = DLookup("[UsrID]", "tblRndUsr", "[Username]='" & Me.Name1 & "'")
    If lUserID > 0 Then
        sUserName = UCase(Me.Name1)

        sUserPwd = DLookup("[Password]", "tblRndUsr", "[UsrID]=" & lUserID)

        If UCase(sUserPwd) = UCase(Me.Password1) Then
            DoCmd.OpenForm "frmInternet1", acNormal
            DoCmd.OpenForm "frmTimer", acNormal

        Else
            MsgBox "Your password was incorrect, please try again."
            Me.Password1 = ""
            Me.Password1.SetFocus
        End If
    End if

Thanks,
Nim
 
How would i go about getting the minutes corresponding to each username to be placed into the textbox of my timer form?
I think
Code:
Forms("frmTimer").TimerTextBox.Value = DLookup("[TimerUsr]", "tblRndUsr", "[Username]='" & Me.Name1 & "'")

how would i implement this into my code to lock a username if it has been used before.
Code:
 lUserID = DLookup("[UsrID]", "tblRndUsr", "[Username]='" & Me.Name1 & "' AND [Used]=False")
Returns only unused user ids
 
Hi JerryKlmns,

Thanks for the response, the first part of the code works well but with the second part, what i need to do is once a user logs in to automatically lock that field.

Thanks,
Nim
 
once a user logs in to automatically lock that field.
just execute the following code
Code:
CurrentDB.Execute "UPDATE tblRndUsr SET [Used]=TRUE WHERE [Username]='" & Me.Name1 & "'"
 
Thanks Mate worked great.

Regards,
Nim
 
Also with regards to the code i pasted above, when the user tries to login and he enters a username that is not on the list i get a runtime error 94 "invalid use of null" and it points to this line

lUserID = DLookup("[UsrID]", "tblRndUsr", "[Username]='" & Me.Name1 & "'")

How can i prevent this from coming up again, i must have a small mistake in the code.

Regards,
Nim
 
Code:
lUserID = DLookup("[UsrID]", "tblRndUsr", "[Username]='" & Me.Name1 & "'") & ""
Then check for empty sting
Code:
If lUserID ="" 
  Then MsgBox ("Not a valid UserID"
  Exit Sub
End If

The exit sub line keeps the user on the login form..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top