Call a subform function from the form?

  • Follow


Hi All,

    	I need to update a couple of text boxes on a subform after a combobox 
on the main form is changed.  What is the syntax for calling a function in a 
subform module from the module for the mainform?

Thanks, Max   
0
Reply Max 3/28/2007 6:51:39 AM

Remove the Private keyword from the Sub declaration line in the subform's 
module.

If the subform is name Sub1, and the procedure is named Text0_AfterUpdate, 
you can then call it like this:
    Call Form_Sub1.Text0_AfterUpdate

An alternative approach would be to move the procedure into a standard 
module. You can pass a reference to the form like this:
    Function DoSomething(frm As Form)
and use frm anywhere you used Me in the subform's module.
To call it from the main form's module:
    Call DoSomething([Sub1].Form)
To call it from the subform's module:
    Call DoSomething(Me)

-- 
Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Max Moor" <maxmoor@remove_hotmail.com> wrote in message 
news:Xns9900F2BAD9169maxmoorhotmailcom@207.46.248.16...
> Hi All,
>
>    I need to update a couple of text boxes on a subform after a combobox
> on the main form is changed.  What is the syntax for calling a function in 
> a
> subform module from the module for the mainform?
>
> Thanks, Max 

0
Reply Allen 3/28/2007 9:56:05 AM


"Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in news:e40yP9RcHHA.1240
@TK2MSFTNGP04.phx.gbl:

> Remove the Private keyword from the Sub declaration line in the subform's 
> module.
> 
> If the subform is name Sub1, and the procedure is named Text0_AfterUpdate, 
> you can then call it like this:
>     Call Form_Sub1.Text0_AfterUpdate
> 

I forgot about the Private keyword.  I was staring right at it, and didn't 
see it.  Thanks Allen.

- Max
0
Reply Max 3/28/2007 11:23:09 PM

2 Replies
1626 Views

(page loaded in 0.056 seconds)

Similiar Articles:













8/1/2012 6:02:42 PM


Reply: