Re: Kick Starting AfterUpdate Event in another Form
From: TC (no_at_email.here)
Date: 04/29/04
- Next message: tina: "Re: Novice having problems executing a macro - Help"
- Previous message: TC: "Re: Updating main form"
- In reply to: Pete Halfacree: "Re: Kick Starting AfterUpdate Event in another Form"
- Next in thread: Pete Halfacree: "Re: Kick Starting AfterUpdate Event in another Form"
- Reply: Pete Halfacree: "Re: Kick Starting AfterUpdate Event in another Form"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 29 Apr 2004 12:17:11 +0930
Pete, if you want to call a procedure or function within a form module from
"outside", you must declare the procedure or function Public:
form #1's module:
PUBLIC sub do_stuff
msgbox "in do_stuff!"
end sub
then from some other form:
forms("... the form name ...").do_stuff
But generally it is not good practice to do that. If two forms call the same
procedure, it is best to declare that procedure in a module on the Modules
table. Declare it Public, as above. Then either form (or any other sub or
function in any module) can call it just by saying: do_stuff.
If it needs to know values from the calling form, just pass those values as
parameters:
declaration of do_stuff in a Module:
Public do_stuff (Blah as Integer)
msgbox "do_stuff! " & Blah
end
calling do_stuff from within a form module, passing the integer value from
control txtBlah:
do_stuff me![txtBlah]
HTH,
TC
"Pete Halfacree" <anonymous@discussions.microsoft.com> wrote in message
news:535101c42cf9$182e68b0$a401280a@phx.gbl...
> TC, Thank you for your prompt response.
>
> Calling the Sub your way can only be done within the form
> having the Event Procedure and this how I have called up
> the Event (based on the GotFocus Event of the Control
> stimulated by the Enter + Back Tab).
>
> I have tried to Run the procedure from the Calendar form
> using:
> Run frm.ActiveControl.Name & "_AfterUpdate [Event
> Procedure]".
> Access tells me it can't find the procedure.
>
> I have also tried Run frm.name & "." &
> frm.ActiveControl.Name & "_AfterUpdate" and still no joy.
>
> Surely there must be a way!
>
> Regards, Pete
> >-----Original Message-----
> >If a control has an event (including but not limited to
> AfterUpdate) - say:
> >
> > private sub ctl_AfterUpdate()
> >
> >you can invoke that event procedure manually, just like
> any other procedure:
> >
> > msgbox "calling.."
> > ctl_AfterUpdate
> > msgbox "called!"
> >
> >From a code structure viewpoint, it may be better to put
> the common code in
> >a seperate procedure:
> >
> > private sub ctl_AfterUpdate()
> > do_stuff
> > end stuff
> >
> > msgbox "calling.."
> > do_stuff
> > msgbox "called!"
> >
> > private do_stuff()
> > ...
> > end sub
> >
> >Now, if you need to add something extra for the
> AfterUpdate case, but not
> >for the "called programatically" case, you can do that
> easily.
> >
> >HTH,
> >TC
>
- Next message: tina: "Re: Novice having problems executing a macro - Help"
- Previous message: TC: "Re: Updating main form"
- In reply to: Pete Halfacree: "Re: Kick Starting AfterUpdate Event in another Form"
- Next in thread: Pete Halfacree: "Re: Kick Starting AfterUpdate Event in another Form"
- Reply: Pete Halfacree: "Re: Kick Starting AfterUpdate Event in another Form"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|