A
Afrosheen
First of all, thanks for reading my post.
I have a pass word form. It has three text boxes in it. Userid, Password,
then a username {text8}.
When I open the form on Open I have the Username not show up. This works.
When the person types in their UserId and Password, depending on their user
level the Username will become visible. The Username textbox will show up but
not stop so the person can enter their name. It just goes right by it and
continues on. I've tried to set focus on the textbox but it still goes pass
it and continues on to the next step. What I was wondering is how can I stop
it so the user can put their name in.
Here is the code:
Private Sub Pword_AfterUpdate()
Dim strUser, userpermission, Text8 As String
Dim rst As DAO.Recordset ' The tLogError table
10 strUser = username
Static counter As Integer
20 If StrComp(Me.Pword, Nz(DLookup("Password", "tblpass", "User=" & """"
& strUser & """"), ""), 0) = 0 Then
30 userpermission = DLookup("[userlevel]", "[tblpass]", "[User] = '" &
strUser & "'")
If userpermission = 2 Then
Me.Text8.Visible = True
Me.Text8.SetFocus
End If
40 If userpermission = 3 Then
50 Call MsgBox("Your user level does not qualify you for this
section.", vbCritical, Application.Name)
60 DoCmd.Close acForm, "frmPass2"
70 Exit Sub
80 End If
90 Set rst = CurrentDb.OpenRecordset("tPassLog", , dbAppendOnly)
100 rst.AddNew
110 rst![Date] = Date
120 rst![User] = strUser
130 rst![Time] = Time()
132 rst![Uname] = Text8
140 rst.Update
150 rst.Close
160 strUser = ""
170 username = ""
180 Pword = ""
190 DoCmd.Close acForm, "frmPass2" 'Closes the password window
200 DoCmd.OpenForm "frmFileMaint", acNormal, OpenArgs:=userpermission
210 Exit Sub
220 Else
230 If counter < 2 Then
240 Call MsgBox("Oh Oh! You Didn't Say the Magic Word!!" _
& vbCrLf & "" _
& vbCrLf & "You Only Get 3 Times To Get It Right" _
, vbCritical, Application.Name)
250 strUser = ""
260 username = ""
270 Pword = ""
280 counter = counter + 1
290 Else
300 DoCmd.Close acForm, "frmPass2"
310 End If
320 End If
End Sub
Thanks for the help.
I have a pass word form. It has three text boxes in it. Userid, Password,
then a username {text8}.
When I open the form on Open I have the Username not show up. This works.
When the person types in their UserId and Password, depending on their user
level the Username will become visible. The Username textbox will show up but
not stop so the person can enter their name. It just goes right by it and
continues on. I've tried to set focus on the textbox but it still goes pass
it and continues on to the next step. What I was wondering is how can I stop
it so the user can put their name in.
Here is the code:
Private Sub Pword_AfterUpdate()
Dim strUser, userpermission, Text8 As String
Dim rst As DAO.Recordset ' The tLogError table
10 strUser = username
Static counter As Integer
20 If StrComp(Me.Pword, Nz(DLookup("Password", "tblpass", "User=" & """"
& strUser & """"), ""), 0) = 0 Then
30 userpermission = DLookup("[userlevel]", "[tblpass]", "[User] = '" &
strUser & "'")
If userpermission = 2 Then
Me.Text8.Visible = True
Me.Text8.SetFocus
End If
40 If userpermission = 3 Then
50 Call MsgBox("Your user level does not qualify you for this
section.", vbCritical, Application.Name)
60 DoCmd.Close acForm, "frmPass2"
70 Exit Sub
80 End If
90 Set rst = CurrentDb.OpenRecordset("tPassLog", , dbAppendOnly)
100 rst.AddNew
110 rst![Date] = Date
120 rst![User] = strUser
130 rst![Time] = Time()
132 rst![Uname] = Text8
140 rst.Update
150 rst.Close
160 strUser = ""
170 username = ""
180 Pword = ""
190 DoCmd.Close acForm, "frmPass2" 'Closes the password window
200 DoCmd.OpenForm "frmFileMaint", acNormal, OpenArgs:=userpermission
210 Exit Sub
220 Else
230 If counter < 2 Then
240 Call MsgBox("Oh Oh! You Didn't Say the Magic Word!!" _
& vbCrLf & "" _
& vbCrLf & "You Only Get 3 Times To Get It Right" _
, vbCritical, Application.Name)
250 strUser = ""
260 username = ""
270 Pword = ""
280 counter = counter + 1
290 Else
300 DoCmd.Close acForm, "frmPass2"
310 End If
320 End If
End Sub
Thanks for the help.