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

one command, two events

Status
Not open for further replies.

rienk

Technical User
Apr 2, 2003
9
US
Hi there,
Can I somehow create or write code so I can have one command on two different events? I've got a really, really long list of commands that I want to execute both on an after-update event and when the entire form loads... anyone?

Thank you,

Rienk
 
If you move the code you want to run into a Private Sub and then call it from both events.

eg.

Private Sub mRunCode()
'
'Your code here
'
End Sub

Private Sub Form_Load()
mRunCode
End Sub

Private Sub Form_AfterUpdate()
mRunCode
End Sub





There are two ways to write error-free programs; only the third one works.
 
Yes. You can.

Create a Private Sub, like this:

Private Sub HelloWorld
MsgBox "Hello World!", VbOkOnly, "Hello"
End Sub

Then under the on and after update subs:
Call HelloWorld

Hope that helps.
 
Thank you!
I know, I am a total idiot when it comes to Access... thanks for helping me out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top