frustrated with program

A

Afrosheen

Thanks for reading my post.
Before I start, sometimes when I post on this forum and I get a reply I can
not open it up to view the reply. So I'm sorry in advance if I don't reply
back. I really need to see the answers so it will give me direction and
guidence.

Now to the problem.

I have a password form with 3 unbound text boxes. The usual User Id,
Password, and if the level is not high enough the third box is supposed to
ask for the users name. Entering the user id and password work ok. When it
comes to checking the level of the user it goes beyond the third text box. It
does display but it doesn't stop to ask the name. Someone suggested that I
use an input box which is ok, but I know that the third text box being unhid
will or should work. I'm open to any suggestions. Maybe I'm doing something
wrong. Here is the code for the whole program:


Private Sub Form_Load()
Me.Text8.Visible = False
End Sub

'---------------------------------------------------------------------------------------
' Procedure : Pword_AfterUpdate
' Author : XXXXXXXX
' Date : 10/15/2008
' Purpose : This is the password sectio
'---------------------------------------------------------------------------------------
'
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 & "'")

40 If userpermission = 3 Then
50 Text8 = InputBox("Please Enter Your Last Name")
'60 Me.Text8.Visible = True
'70 Me.Text8.SetFocus
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 again
 
A

AccessVandal via AccessMonster.com

Well, first learn how to use the forum to reply back.

1. Why Dim Text8?
2. I don't see any difference by using input box to fill Text8.
3. Does the code do what you want.
4. Did it gave you any error and what number and description.

Else, go back to the old post and ask the one who gave you the code.
Thanks for reading my post.
Before I start, sometimes when I post on this forum and I get a reply I can
not open it up to view the reply. So I'm sorry in advance if I don't reply
back. I really need to see the answers so it will give me direction and
guidence.

Now to the problem.

I have a password form with 3 unbound text boxes. The usual User Id,
Password, and if the level is not high enough the third box is supposed to
ask for the users name. Entering the user id and password work ok. When it
comes to checking the level of the user it goes beyond the third text box. It
does display but it doesn't stop to ask the name. Someone suggested that I
use an input box which is ok, but I know that the third text box being unhid
will or should work. I'm open to any suggestions. Maybe I'm doing something
wrong. Here is the code for the whole program:

Private Sub Form_Load()
Me.Text8.Visible = False
End Sub

'---------------------------------------------------------------------------------------
' Procedure : Pword_AfterUpdate
' Author : XXXXXXXX
' Date : 10/15/2008
' Purpose : This is the password sectio
'---------------------------------------------------------------------------------------
'
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 & "'")

40 If userpermission = 3 Then
50 Text8 = InputBox("Please Enter Your Last Name")
'60 Me.Text8.Visible = True
'70 Me.Text8.SetFocus
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 again
 
A

Afrosheen via AccessMonster.com

Thanks for you input.
This was a new post and I still couldn't see it. I got to see this post
through Access Monster.

On the input box the person that gave that to me just suggested that I use
the input box because it stops and asks for the user name.

If userpermission = 3 Then
Me.Text8.Visible = True
Me.Text8.SetFocus
End If

The If Then works and shows the Textbox. The SetFocus I don't believe works
because it continues from the end if after the Me.Text8.Visible = True

Thanks again for the help.
Well, first learn how to use the forum to reply back.

1. Why Dim Text8?
2. I don't see any difference by using input box to fill Text8.
3. Does the code do what you want.
4. Did it gave you any error and what number and description.

Else, go back to the old post and ask the one who gave you the code.
Thanks for reading my post.
Before I start, sometimes when I post on this forum and I get a reply I can
[quoted text clipped - 76 lines]
Thanks again
 
A

AccessVandal via AccessMonster.com

Could be a timing issue. The textbox needs to be visible first. Try moving
the setfocus to after the line 80 or after line 150.

But you're closing "frmPass2". Is this the login form? Why setfocus if you're
closing it?
Thanks for you input.
This was a new post and I still couldn't see it. I got to see this post
through Access Monster.

On the input box the person that gave that to me just suggested that I use
the input box because it stops and asks for the user name.

If userpermission = 3 Then
Me.Text8.Visible = True
Me.Text8.SetFocus
End If

The If Then works and shows the Textbox. The SetFocus I don't believe works
because it continues from the end if after the Me.Text8.Visible = True

Thanks again for the help.
Well, first learn how to use the forum to reply back.
[quoted text clipped - 10 lines]
 
A

Afrosheen via AccessMonster.com

Setting the focus beyond line 80 or after 150 didn't make it stop and "ask"
for information. It was like the Energizer Bunny. It kept going.

The frmPass2 is the login form. The only reason I'm wanting to ask the third
question: "Enter your name" is so I can check and see who is actually
accessing a File menu form. The frmPass2 is just a general password form and
there may be 3-4 people using the database. Because of that I wanted to set
up a general password. Something those 3-4 people would know. The name is
just an added item for me.

I don't know maybe what I want can't be done. If not then I'll either let it
go or try and come up with something else. Maybe reverse. Have all three
boxes show up then if the level of security is higher then hide the box.

Thanks for helping.
Could be a timing issue. The textbox needs to be visible first. Try moving
the setfocus to after the line 80 or after line 150.

But you're closing "frmPass2". Is this the login form? Why setfocus if you're
closing it?
Thanks for you input.
This was a new post and I still couldn't see it. I got to see this post
[quoted text clipped - 18 lines]
 
A

AccessVandal via AccessMonster.com

You have to give more details, what is "didn't make it stop and "ask"". As
far as I see it, that's normal. What input did you do to the controls that
might skip the code?.

What/which part of the code does not work? Can you give more details on how
the form works?
Setting the focus beyond line 80 or after 150 didn't make it stop and "ask"
for information. It was like the Energizer Bunny. It kept going.

The frmPass2 is the login form. The only reason I'm wanting to ask the third
question: "Enter your name" is so I can check and see who is actually
accessing a File menu form. The frmPass2 is just a general password form and
there may be 3-4 people using the database. Because of that I wanted to set
up a general password. Something those 3-4 people would know. The name is
just an added item for me.

I don't know maybe what I want can't be done. If not then I'll either let it
go or try and come up with something else. Maybe reverse. Have all three
boxes show up then if the level of security is higher then hide the box.

Thanks for helping.
Could be a timing issue. The textbox needs to be visible first. Try moving
the setfocus to after the line 80 or after line 150.
[quoted text clipped - 7 lines]
 
A

AccessVandal via AccessMonster.com

Afrosheen said:
Setting the focus beyond line 80 or after 150 didn't make it stop and "ask"
for information. It was like the Energizer Bunny. It kept going.
PS.
One at a time.
1.Did the setfocus works?
2.Did it work the way you wanted?

Like I said, why close this form? Can you use another event to close this
form?
 
A

Afrosheen via AccessMonster.com

The set focus did not stop it. It just continued on. Maybe it would help if I
sent you the whole program.
I close the form because it will open another form called frmFileMaint.

Here is the whole program. I'm sorry if I've been vague.

Private Sub Pword_AfterUpdate()
Dim strUser As String
'Dim userpermission As Integer

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 & "'")

40 If userpermission = 3 Then
'50 Text8 = InputBox("Please Enter Your Last Name")
60 Me.Text8.Visible = True
70 Me.Text8.SetFocus
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
 
A

AccessVandal via AccessMonster.com

So, you're saying the form close after the user can key in the "Text8" entry?
Look at modified code below.

Private Sub Pword_AfterUpdate()
Dim strUser As String
'Dim userpermission As Integer

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 & "'")

40 If userpermission = 3 Then
'50 Text8 = InputBox("Please Enter Your Last Name")
60 Me.Text8.Visible = True
70 Me.Text8.SetFocus
71 Exit Sub ‘ you must exit the code if you want to use Text8
‘And in Text8 AfterUpdate event, continue with inserting
‘record and close the form.

80 Else ‘ if not userpermission = 3 continue

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
330 End if
End Sub

Private Sub Text8_AfterUpdate()
‘do whatever here then close the form
‘validate Text8 user entry and insert record
‘if true then close form
End Sub
 
A

Afrosheen via AccessMonster.com

Thanks, I'll try it out. I appreciate the help..


So, you're saying the form close after the user can key in the "Text8" entry?
Look at modified code below.

Private Sub Pword_AfterUpdate()
Dim strUser As String
'Dim userpermission As Integer

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 & "'")

40 If userpermission = 3 Then
'50 Text8 = InputBox("Please Enter Your Last Name")
60 Me.Text8.Visible = True
70 Me.Text8.SetFocus
71 Exit Sub ‘ you must exit the code if you want to use Text8
‘And in Text8 AfterUpdate event, continue with inserting
‘record and close the form.

80 Else ‘ if not userpermission = 3 continue

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
330 End if
End Sub

Private Sub Text8_AfterUpdate()
‘do whatever here then close the form
‘validate Text8 user entry and insert record
‘if true then close form
End Sub
The set focus did not stop it. It just continued on. Maybe it would help if I
sent you the whole program.
I close the form because it will open another form called frmFileMaint.

Here is the whole program. I'm sorry if I've been vague.
 
A

Afrosheen via AccessMonster.com

Another quick question. After the person puts their name in then the exit sub
correct? Now what would happen if I close the form and open the other form?
Would that make any difference?

Thanks again.
Thanks, I'll try it out. I appreciate the help..
So, you're saying the form close after the user can key in the "Text8" entry?
Look at modified code below.
[quoted text clipped - 66 lines]
 
A

AccessVandal via AccessMonster.com

If you're talking about "Text8" AfterUpdate event, did you input codes as in
the Pword_AfterUpdate event? A similiar code in the Text8_AfterUpdate event
will close the form as well as insert entry in the table. Did you include the
code into Text8 control?
 
A

Afrosheen via AccessMonster.com

No I didn't. Not thinking straight. I'll do that and that should take care of
it.

Thanks again..
 

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