Redirect for username admin

Timoty

Registered User.
Local time
Today, 10:57
Joined
Jul 29, 2003
Messages
105
I will try to be short winded.
I have a databse that works. However, I want to open a different form if the user is admin (username admin) than all the other users.

What I have does not work. It opens the regular form that all the others use.

Regular user form = time
admin form = timeadmin

On got focus the following code runs:

Me.Requery

If [Forms]![login]![pwcheck] = [Forms]![login]![PW] And [Forms]![login]![userid] = "Admin" Then

DoCmd.OpenForm "timeadmin"
Cancel = True

If [Forms]![login]![pwcheck] <> [Forms]![login]![PW] Then
MsgBox "Please Try Again", vbOKOnly, "Invalid Password or USER ID!"
Cancel = True

End If

If Me.PW = "password" Then
MsgBox "This is the first time using the database or your passowrd has been reset." & Chr(13) & _
"You must change your password before you can enter the database.", _
vbOKOnly + vbExclamation, "Change Password"

DoCmd.OpenForm "chgpw"
End If

ElseIf [Forms]![login]![pwcheck] = [Forms]![login]![PW] Then
Dim stDocName As String

stDocName = "TIME"
DoCmd.OpenForm stDocName
Cancel = True
End If

Exit_Command12_GotFocus:
Exit Sub

Err_Command12_GotFocus:
MsgBox "Your Not in The Database", vbOKOnly, "Exiting Database Goodbye!"
Cancel = True
DoCmd.Quit
End Sub


I've been going in circles for hours. Please help me. My brain hurts.:( :(
 
buggy

Figure this one out.

I changed the name of the form from timeadmin to aa....out of desperation.....and it worked.

Why it wouldn't work with the name timeadmin and it will with the form name aa (I just picked the name out of a hat)...is beyond me.

Whatever, it can be called aa now that I have wasted an hour of my time.

Has anyone else ever ran into a problem like this where access just doesn't seem to like a name you have given to a form or any object for that matter?:confused: :confused: :confused:
 
I have seen it. Rarely but it has happend to me before. Sometimes Access does not recognize an object name "change" until you close the db and then reopen it.

Also, Time is a reserved VBA key word since Time() is a function. You should not name any objects that are reseved VBA keywords.

HTH
 
did that

I had opened and closed the db many times with no effect. The name was actually timeadmin. Maybe anything starting with time messes access up.

As I am learning VB as I go, the hassle was that I thought I had a problem with code the whole time. Makes me wonder if other code I have tried in the past was actually OK, and I moved on and skipped an idea I had dreamed up when, in theory, it should have worked. I guess that is why a formal educatin in VB would be an assett.

:)
 

Users who are viewing this thread

Back
Top Bottom