Should be a easy question (1 Viewer)

Cpar

Registered User.
Local time
Today, 01:20
Joined
Jan 9, 2016
Messages
41
Hey guys i put a password on a button but i am having trouble with one part. See i need to put the code in my form "on current" and "after update". If you guys could help me revise this code that would be awesome. Here it is.

Private Sub Check1503_Click()
Dim Mypassword
Mypassword = InputBox("Enter Password", ("Password"))
If Mypassword = "12345" Then
Me.Sig.Visible = True
Else
Me.Sig.Visible = False
End If
End Sub

If i put it in just like this it asks for the password at weird times.
 

jdraw

Super Moderator
Staff member
Local time
Today, 02:20
Joined
Jan 23, 2006
Messages
15,394
Did you step through your code?
What error?
 

Cpar

Registered User.
Local time
Today, 01:20
Joined
Jan 9, 2016
Messages
41
Sorry im not sure what step through my code means? If i just take out the Private Sub Check1503_Click() part every time i open my form it asks me for the password. I do not want that. I want to have to click the button. If i leave Private Sub Check1503_Click() as part of the code under the "on current" it gives me a error.
 

jdraw

Super Moderator
Staff member
Local time
Today, 02:20
Joined
Jan 23, 2006
Messages
15,394
Sorry im not sure what step through my code means?

Go to the debugging tips link in my signature.

It is asking you for a password because you have told it to do so
Code:
Mypassword = InputBox("Enter Password", ("Password"))
 

Cpar

Registered User.
Local time
Today, 01:20
Joined
Jan 9, 2016
Messages
41
Ok i tried reading through the debugging tips. Tried pressing F8. Idk why but its not working for me. All i know is when i put
Dim Mypassword
Mypassword = InputBox("Enter Password", ("Password"))
If Mypassword = "12345" Then
Me.Sig.Visible = True
Else
Me.Sig.Visible = False
End If

In the "on current section of my form it asks me for the password right away. I need it to somehow ask me for it when i press the button.
 

bob fitz

AWF VIP
Local time
Today, 07:20
Joined
May 23, 2011
Messages
4,726
In the "on current section of my form it asks me for the password right away. I need it to somehow ask me for it when i press the button.
Then perhaps you just need your code in the buttons On Click event
 

Cpar

Registered User.
Local time
Today, 01:20
Joined
Jan 9, 2016
Messages
41
I have the code in the button on click event.
 

Cpar

Registered User.
Local time
Today, 01:20
Joined
Jan 9, 2016
Messages
41
Yes. I guess my question is idk how to code it into the "on current" section
 

Cpar

Registered User.
Local time
Today, 01:20
Joined
Jan 9, 2016
Messages
41
Any idea on how to convert the code? to make it work with the "on current"
 

jdraw

Super Moderator
Staff member
Local time
Today, 02:20
Joined
Jan 23, 2006
Messages
15,394
Do you have the code in the onclick event of your button?
 
Last edited:

bob fitz

AWF VIP
Local time
Today, 07:20
Joined
May 23, 2011
Messages
4,726
I am confused.

In post #6 I quoted some of your text from post #5 which I took to mean that the code was running in the Forms On Current event already but that you just needed it to run when the button was clicked, hence my reply in post # 7.
 

Cpar

Registered User.
Local time
Today, 01:20
Joined
Jan 9, 2016
Messages
41
Sorry if i am being confusing. I have this code in my "on click" button.
Private Sub Command1502_Click()
Dim Mypassword
Mypassword = InputBox("Enter Password", ("Password"))
If Mypassword = "12345" Then
Me.Sig.Visible = True
Else
Me.Sig.Visible = False
End If
End Sub

I now need to write some code that will go in my "On current" form command. So if i do it to one it does not affect the rest of my forms. Does this make more sense? I hope so. Let me know if it is still confusing.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 07:20
Joined
Sep 12, 2006
Messages
15,710
why would you want to click a button to then enter a password?

just have an unbound textbox with a label of "password", and set the text box format to "password".

then test the password in the afterupdate event of the textbox

with an inputbox you can't hide the password from someone watching over your shoulder.
 

jdraw

Super Moderator
Staff member
Local time
Today, 02:20
Joined
Jan 23, 2006
Messages
15,394
Further to Dave's post, can you describe to us in simple terms What you are trying to do? Readers are attempting to answer, but, in my view, they still aren't sure what it is you are trying to accomplish.
 

Cpar

Registered User.
Local time
Today, 01:20
Joined
Jan 9, 2016
Messages
41
Yes i can try and describe better. Once again sorry. I am trying to make a button on my form that when clicked it will ask for a password. If the password is correct it will then show a picture. If the password is not correct it will not show the picture. So i have a button with this code in it

Private Sub Command1502_Click()
Dim Mypassword
Mypassword = InputBox("Enter Password", ("Password"))
If Mypassword = "12345" Then
Me.Sig.Visible = True
Else
Me.Sig.Visible = False
End If
End Sub

I do not want one form to affect my others. (Split Form, I can just click on different rows). So i need code to go into my form "on current" This is what i am having trouble with
 

bob fitz

AWF VIP
Local time
Today, 07:20
Joined
May 23, 2011
Messages
4,726
What happens if you copy your code to the forms on current event
 

Cpar

Registered User.
Local time
Today, 01:20
Joined
Jan 9, 2016
Messages
41
If i put this

Dim Mypassword
Mypassword = InputBox("Enter Password", ("Password"))
If Mypassword = "12345" Then
Me.Sig.Visible = True
Else
Me.Sig.Visible = False
End If

Into my form "on current" event it asks me for a password right when the form opens. I do not want this to happen. I want to actually have to push the button for it to ask me the password. Thanks for the reply Bob fitz.
 

bob fitz

AWF VIP
Local time
Today, 07:20
Joined
May 23, 2011
Messages
4,726
In your post #16 you said:
So i need code to go into my form "on current" This is what i am having trouble with
but in your post #19 you contradict yourself (again) saying:
Into my form "on current" event it asks me for a password right when the form opens. I do not want this to happen
I'm sorry, but don't think I can offer anything more on this subject.
 

Users who are viewing this thread

Top Bottom