-
Trigger a Form Event?
Does anyone worked out how to trigger a form event programmatically? As a trivial example, how might I trigger the form 'On Activate' event from another form? I suspect that I'd have to watch the messages going to the form as it starts up and then use a Win32 SendMessage call. Has anyone done this? Thanks in advance/
-
The easiest way is to write a global function that performs the same task, then call that. Nothing says that you can't make modules for each form if necessary. It isn't pretty, and it may not be what you're after, but it should work.
-
thanks, that's what I did
As I said in the subject line, that's what I did as a workaround, but I was curious if anyone had actually written the code to fire non-custom events.
-
How to Fire a Forms Event from Code
Open the form and change the scope of the event from Private to Public.
Easy as that.
To call it
Forms("myform").Form_Activate
If you are using Access 2000 or XP you can create and raise custom events in class modules.
eg
Private Event DataChanged(Cancel as Boolean)
In AC97 > you can Dim objects With Events.
Private WithEvents mfrm As Form_f2
The event sinks for the object will become available.
You can only use this method if you are instantiating the form via
Set frm2 = new Form_f2
HTH,
Peter
-
Fantastic! Of course! Thanks
Now why didn't I think of that? Thanks for your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|