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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running a OnClick_subrotine Using other events 1

Status
Not open for further replies.

sanan

Technical User
Apr 15, 2004
139
IR
Hi Evrey body
this sort of general question.
I have subrotine, which is working, I want to call it to be run by another event let's say closing of a Form.
how can I do it?
and what would be the code if I wanted to press a Button by Code?

Best regards
sanan
 
something like should work for pressing a button, or calling any other subroutine:

Code:
private sub form_open()
    command0_click
end sub

simple, eh?

- RoppeTech
 
Hi roppetech
Thanks a lot.
That worked.
One other note on this issue.
Could you do the same by Making a Function of my Sub.
Lets call my Sub:
Private Sub AcceptQoute_Click()

best regards
sanan
 
I'm not sure what you mean, but functions are pretty much the same thing.
You can do one of these:

Code:
Public Function AcceptQuote(strAmount as String, strName as String)
     msgbox "Thank you, " & strName & " for accepting this quote of " & strAmount
     ...
End Function

Followed up by a few of these:

Code:
Private Sub AcceptQoute_Click()
     AcceptQuote(txtPrice, txtName)
End sub

Private Sub OtherPlaceYouWantToAcceptQuote_Click()
     AcceptQuote(txtDiscountPrice, "FooBar")
End Sub

- RoppeTech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top