Re: Kick Starting AfterUpdate Event in another Form
From: TC (no_at_email.here)
Date: 04/30/04
- Next message: Rohit Thomas: "Re: ComboBox Filter"
- Previous message: tina: "Re: Test for no records returned"
- In reply to: Pete Halfacree: "Re: Kick Starting AfterUpdate Event in another Form"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 30 Apr 2004 11:04:39 +0930
"Pete Halfacree" <NoSpamPeter.Halfacree@baesystems.com> wrote in message
news:5c2801c42dc7$980f0700$a401280a@phx.gbl...
> TC,
>
> This is the response I was looking for.
>
> I will take your comments "On Board" about using Public
> Modules, although I will have to analyse my Process again.
Hi Pete. Note that I meant "the procedure or function", not "the module",
when I used the word "it" in the second sentence: "If two forms call the
same procedure, it is best to declare that procedure in a module on the
Modules tab. Declare >it< Public ..." That is, declare the procedure or
function Public, not the module. It is not a "public module". It is properly
called a "standard" module (as opposed to a "class" module).
>
> Thank you once more.
No probs, good luck.
TC
>
> Regards,
>
> Pete
> >-----Original Message-----
> >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: Rohit Thomas: "Re: ComboBox Filter"
- Previous message: tina: "Re: Test for no records returned"
- In reply to: Pete Halfacree: "Re: Kick Starting AfterUpdate Event in another Form"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|