Passwords & Command Buttons (1 Viewer)

melvis

Registered User.
Local time
Today, 05:51
Joined
Aug 2, 2002
Messages
40
Hi all,

I'm having a problem trying to get some code to work that a member of this forum helped me with some years ago. Basically I have a form with a combobox that is used to select the user name and a textbox for the password to be entered. There are two different types of user, manager and clerk. The logon button must open the selection screen form but if the user is a clerk, then the delete client command button must be disabled.

I keep getting a 'Compile Error stating Block If without End If' and I'm not sure where I'm going wrong.

I'm also not sure what code I should be writing to disable the command button dependant on user.

I know this is not great security, but it's only going to be used as an interim solution for 4 people (none with access experience). Can anyone please explain to me why I'm getting the compile error and what code I would need to disable the command button on the form and where I would need to put it.

Many thanks.

Here is the code:

If Me.Password = Me.Combo10.Column(4) Then
If Combo10.Column(3) = "Manager" Then
DoCmd.OpenForm "frm_Splash_Screen"
ElseIf Me.Password = Me.Combo10.Column(4) Then
If Combo10.Column(3) = "Clerk" Then
DoCmd.OpenForm "frm_Splash_Screen"
End If
Else
Msgbox "Incorrect Password, try again"
End if
 

maxmangion

AWF VIP
Local time
Today, 05:51
Joined
Feb 26, 2003
Messages
2,805
you have 3 if statements, but two closing End If, you need to add another End If.
 

melvis

Registered User.
Local time
Today, 05:51
Joined
Aug 2, 2002
Messages
40
Hi maxmangion,

Thanks for the response. I've tried adding another End If underneath the first line of code (before the Else If) and all it does is pop up with my message box.

Is there anywhere else I should add this?

Thanks
 

ghudson

Registered User.
Local time
Today, 00:51
Joined
Jun 8, 2002
Messages
6,194
Using the CODE tags ]CODE[ ]/CODE[ [click the # button!] will help those help you so that your code is easier to read. This is my interpretation of what you want.

Code:
If Me.Password = Me.Combo10.Column(4) Then
    If Combo10.Column(3) = "Manager" Then
        DoCmd.OpenForm "frm_Splash_Screen"
    ElseIf Me.Password = Me.Combo10.Column(4) Then
        If Combo10.Column(3) = "Clerk" Then
            DoCmd.OpenForm "frm_Splash_Screen"
        End If
    End If
Else
    MsgBox "Incorrect Password, try again"
End If
 

melvis

Registered User.
Local time
Today, 05:51
Joined
Aug 2, 2002
Messages
40
Thanks for replying ghudson, I've never posted code before so thanks for the tip.

I'm still having the same problem as before though, when I open the form and pick a UserName from the combobox and then enter the password, it pops up with the incorrect password msgbox.

My original table has 4 columns, 1-Name, 2-UserName, 3-Level & 4-Password. Is there a problem with the coloumn lookup do you think????

I am hoping (eventually) to get the splashscreen to open up with the delete client command button enabled for managers and disabled for clerks. Do I need to put some code underneath the Manager level code to make sure that when the splashscreen opens, the delete client is enabled and vice versa for the clerks? Otherwise, at the moment isn't the code doing the same thing? :confused:

Thanks again.
 
Last edited:

bruced3846

Registered User.
Local time
Today, 00:51
Joined
May 4, 2005
Messages
15
Why not ...

Since the only if condition for the primary is password, and the first column number is 0, then password = combo10.column(3)

Code:
If Me.Password = Me.Combo10.Column(3) Then
     If Combo10.Column(2) = "Manager" Then DoCmd.OpenForm "frm_Splash_Screen"
     If Combo10.Column(2) = "Clerk" Then DoCmd.OpenForm "frm_Splash_Screen"
Else
     Msgbox "Incorrect Password, try again"
End if

Right?

Bruce Davis

Yes, it is doing the same thing. You could just have two different splashscreens, one with the button enabled, one without...
 
Last edited:

melvis

Registered User.
Local time
Today, 05:51
Joined
Aug 2, 2002
Messages
40
Thankyou, thankyou, thankyou!!!!

You've made a bad day a lot better, thanks!

Just one more quick question if could be so bold.

When I close the splash screen down, the login screen appears (which is fine), but the password is still displayed (masked with ***'s though). Is there anyway to delete the password text so that when opening up that screen users cant just click logon as the last user?

Regards
Melvis
 

bruced3846

Registered User.
Local time
Today, 00:51
Joined
May 4, 2005
Messages
15
Hmm... you mean you have a logon screen, they enter username/password, splash screen pops up, and when you close popup the logon is STILL displayed? If so, you could do something as an [Event Procedure] in the OnClose event of the splashscreen to close the logon form. An abundance of caution suggests that you do it in code, so you can check to see if the logon screen is still open before attempting to close it...

Code:
Private Sub Form_Close()
 If IsLoaded("frmLogon") Then DoCmd.Close acForm, "frmLogon"
End Sub

Bruce
 

melvis

Registered User.
Local time
Today, 05:51
Joined
Aug 2, 2002
Messages
40
Hi Bruce,

Thanks for your help, I'll try that out as soon as I can. At the moment, everytime I try and save the changes to the form I'm getting an array of messages like: save operation failed or couldn't update currently locked to memory messages.

Have no idea what's going on so I think I'm gonna give up for the day and go home and tackle it on Monday. Thanks again.

Melvis
 

Users who are viewing this thread

Top Bottom