954,557 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Control button Click event

Guys,

I have a question, is there any way in code to determine if a button has been clicked? I want to use one form when a control button on a second form is click; I do not know how to do that, though I know it goes something like this :

if UserForm1.CommandButton. <I do not know what goes in here  >  = true Then
 
endif



Please can somebody help me out? Thank you very much.

Ini

INI
Light Poster
39 posts since May 2006
Reputation Points: 13
Solved Threads: 0
 

Hi

Are you trying to open up a different form - let's say form2 - from the click on a button on form1?

why don't you use the event created by the button? and then open up the form.

something like this:

Private Sub button1_Click() 

     form2.show
    
End Sub


where button1 is the name of the button in form 1.

hope it helps

williamrojas78
Junior Poster
111 posts since Jun 2005
Reputation Points: 23
Solved Threads: 10
 

I have form A that has 4 control buttons(A,B,C,and D), I have Form B which will be called up when each of these 4 buttons are pressed. I want when control A is pressed, it will open Form B with Form B title saying "A". If Control Button B is press, Form B will Open up with its label saying "B" and so on.

I hope this helps make my problem easier to answer. I am trying to use the same form for 4 different things.

INI


No, I am trying to determine if the control button on Form 1 was clicked. If

INI
Light Poster
39 posts since May 2006
Reputation Points: 13
Solved Threads: 0
 

Ah, ok

this is the code for the four buttons on formA

Private Sub Command1_Click()
Form2.Show
Form2.Label1.Caption = "A"
End Sub

Private Sub Command2_Click()
Form2.Show
Form2.Label1.Caption = "B"
End Sub

Private Sub Command3_Click()
Form2.Show
Form2.Label1.Caption = "C"
End Sub

Private Sub Command4_Click()
Form2.Show
Form2.Label1.Caption = "D"
End Sub


where Command1, Command2, Command3 and Command4 are the buttons, and label1 in form2 will change everytime you hit a button

williamrojas78
Junior Poster
111 posts since Jun 2005
Reputation Points: 23
Solved Threads: 10
 

Thank you very much, I will try that.

Ini :)

INI
Light Poster
39 posts since May 2006
Reputation Points: 13
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You