Raising Events

A

Art

Hi,

I've got a form "frmLoadAccount" with a label on it "uxLoad".
My form has the following code in it:

Public Event testEvent()

Private Sub uxLoad_Click()
RaiseEvent testEvent
End Sub

(I like labels better than buttons)


I have a class "Account" with the following code in it:

Public WithEvents xFrm As frmLoadAccount

Public Sub Init()
Set xFrm = New frmLoadAccount
xFrm.Show
End Sub

Public Sub xFrm_testEvent()
Stop
End Sub

My hope was that by clicking on the "uxLoad", I would trigger "testEvent",
and run the "xFrm_testEvent". The debugger gets to the RaiseEvent statement,
but then nothing. Am I doing something wrong?

I tried to do this by running a sub inside the code for the form and that
DID work. I'm wondering if there's a problem because I try to raise an event
from within an event handler.

I'd appreciate any help.
 
A

Art

Stringer,

Thanks for getting back to me. My problem is a little different. I'm not
trying to call a macro, I'm trying to raise an event which would cause code
to execute in another macro. Now it may be that my solution is to just call
the other macro -- I'm not sure, but it's late and I'm not thinking as
clearly as I should.

Even if abandoning my approach is the best answer, I still wonder about
raising an event within an event handler.
 

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