In need of Else Code statemet

avenger619

Registered User.
Local time
Today, 05:01
Joined
Jan 2, 2013
Messages
49
Hi Guys,

Currently I have this bottom code on a check mark, but I want my Else code to reflect no change. So if password is not accepted then no change, can anyone help with proper code? Very much appreciated. Thank you

Private Sub Sold_Click()
If InputBox("Enter Password", "Approved") = "12345" Then
Me!Sold = True
Me!Sold.Visible = True
Else
Me!Sold = "if password is not accepted then no change"
End If
End Sub
 
If your Sold field is a text box quote marks are require for your text If yes/no then no quote marks

Code:
If InputBox("Enter Password", "Approved") = "12345" Then

Me!sold.Visible = "True"
Me.Sold = "True"
Else
Me!Sold = "False"
Me!sold.Visible = "False"
End If
Code:

I hope i have understood your question
 
ypma, I originally tried that code, but the downside is that if no password is accepted then it changes true to false right off the bat.

Example: Let say I go ahead as manager click & add correct password, it changes it to true. But if an employee goes back and click on it adds incorrect password it changes it to false basically overwriting me.

So, I was hoping for an Else code that does nothing or no change so it keeps the original one.
 
If there is no code in the Else part then nothing will happen.

Else
End if

Brian
 
Don't make your user type her password to click a check box. It's overkill. Get the user to log in and if the user is authorized, enable the check box.
 
lagbolt, this is interesting.

cause I have about 10-20 fields that are password protected, so you can imagine the hassle. lol

How do I go about establishing something like that?
 
Brian has hit nail on the head.
From your example you do not need an " Else" as changes will only be made when the correct password is entered and therefore your True will not be overwritten!!
 
Hi Guys,

Currently I have this bottom code on a check mark, but I want my Else code to reflect no change. So if password is not accepted then no change, can anyone help with proper code? Very much appreciated. Thank you

Private Sub Sold_Click()
If InputBox("Enter Password", "Approved") = "12345" Then
Me!Sold = True
Me!Sold.Visible = True
Else
Me!Sold = "if password is not accepted then no change"
End If
End Sub

The rule strikes me as strange. First, if you don't want anything to happen on an incorrect password then the ELSE part of the IF statement is redundant. Second, if the original state of Me!Sold is True then why click the button if the outcome is always True ? So I would - after the original successful setting of Me!Sold disable the button. It serves no useful purpose if the input cannot change the value of Me!Sold. You follow ?

Best,
Jiri
 
Present the user at startup with a login window and give him the option to enter his password. If he supplies a valid password, set some system global flag. Then, when a form opens it can check that flag, and conditionally enable or disable certain controls.
 
Solo, So I tried this option which does not work quite right. As I scroll through the Applicant records its disable for all:banghead:.

Private Sub Sold_Click()
If InputBox("Enter Password", "Approved") = "dfl545" Then
Me!Sold = True
Me!Sold.Visible = True
Me!Sold.Locked = True

Else

Me!Sold = Disable

End If
End Sub
 
Solo, So I tried this option which does not work quite right. As I scroll through the Applicant records its disable for all:banghead:.

Private Sub Sold_Click()
If InputBox("Enter Password", "Approved") = "dfl545" Then
Me!Sold = True
Me!Sold.Visible = True
Me!Sold.Locked = True

Else

Me!Sold = Disable

End If
End Sub

What I was suggesting is something like

Code:
Private Sub Sold_Click()
If not Me!Sold = True Then  
    If InputBox("Enter Password", "Approved") = "dfl545" Then
      Me!Sold = True
      ' This greys out the button, prevents the setting of Me!Sold to False
      Sold_Click.Enabled = False  
    End If
End If
End Sub[/QUOTE]

Best,
Jiri
 

Users who are viewing this thread

Back
Top Bottom