Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I code a button click

Status
Not open for further replies.

ViperD

IS-IT--Management
May 1, 2003
27
0
0
US
I have a button on a from that I have not been able to find the code behind it's OnClick event. Is there a way to write code that is the same as clicking on the button?
 
ViperD,
right click, properties, event, choose the one you want.
balance is left as an excercise for the user.
regards,
longhair
 
I'm trying to write VBA code behind the onClick event that is the same as having a user click on a different button. Lets say I have button1 that adds 1+2, and I have button2 that does something else, but it requires button one to have been clicked already.

I would copy the code behind the onclick event in button1 but there is no code in VBA.
 
What about writing a simple if...then procedure that makes the second button's enabled property go to "no" if the first button hasn't been clicked.

As far as not being able to find the code, it's possible that none exists yet or that something has caused it to get deleted. If your OnClick event does have an event or a macro listed, then, most likely, nothing is there and you will have to write (or re-write it).

Hope this helps.

mrmetal
 
ViperD,

You can call button1's click event procedure from within button2's click event procedure:
Code:
Private Sub button1_Click()
Dim iMyNum As Integer
iMyNum = 2 + 1
End Sub
---------------------------
Private Sub button2()
Call button1_Click()
[green]'now do other stuff[/green]
End Sub
HTH,

Ken S.
 
ViperD,

I just re-read your second post and I'm a little confused... Are you saying there is no VBA code in button1's click event procedure? Then what happens when button1 is clicked? Is it a macro?

Ken S.
 
ViperD,

as Eupher said, or is it a function directly named, in the Onclick event?

have you beren to the properties dialog for that button, or have you just checked the VBE WINDOW?
 


You make the initialized Visible property FALSE for the second button.

When the FIRST button is clicked, then set the Visible property of the second button TRUE.

Skip,
[sub]
[glasses] [red]Be advised:[/red]To be safe on the FOURTH, don't take a FIFTH on the THIRD, or...
You might not come FORTH on the FIFTH! [bomb][tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top