Multiple events possible?

G

Guest

Is it possible to have 2 things run in the OnOpen event of a form? I need to
add

Application.SetOption "Default Find/Replace Behavior", 2

to the OnOpen event of my switchboard (which is my startup form), but
there's already an event procedure there (created by the Switchboard
Manager). I tried plugging the above command into the event procedure, but I
don't know anything about Visual Basic, so of course it's not working.

Please let me know if there is other information I need to provide. Thanks.
 
G

Guest

An event procedure can accomodate any code you want to run. If this isn't
working, it's for another reason.

Please post the code you are trying to run.

Barry
 
G

Guest

I just added

Public Sub findreplace()
Application.SetOption "Default Find/Replace Behavior", 2
End Sub

to the end of the code that was already in there. Now, you're probably
going, "well, duh, that's not how you write it!" but please understand I
really know ABSOULUTELY NOTHING about Visual Basic and just made it up based
 
D

Douglas J. Steele

Presumably you had something like:

Private Sub Form_Open(Cancel As Integer)

' some code here.

End Sub

Simply add that one line of code (Application.SetOption "Default
Find/Replace Behavior", 2) to that sub above:

Private Sub Form_Open(Cancel As Integer)

' some code here.

Application.SetOption "Default Find/Replace Behavior", 2

End Sub


Alternatively, keep the findreplace sub you've already added, and just call
it from the Form_Open event:

Private Sub Form_Open(Cancel As Integer)

' some code here.

Call findreplace

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top