Subject Re: Referencing a subform
From Ken Mayer <>
Date Thu, 30 Nov 2023 10:28:22 -0800
Newsgroups dbase.getting-started

On 11/30/2023 8:27 AM, Tim Ward wrote:
> Hi,
> I have a subform on a form opened by a pushbutton like below and works
> OK for what I need.
> function PB_Subform_onClick()
>      f = this.parent.form
>      set procedure to DeliveryList.wfm additive
>         x = new DeliveryListForm( f, "Mypopup" )
>    := 10
>         x.left    := 20
>        return
> In the main form I have some custom pushbuttons and when I click one of
> these I want to action different things on the subform, like refreshing
> the grid there or changing a text field.
> What's the correct syntax as I can't seem to get it right. So below is a
> line setting the value stored as a custom property of the pushbutton
> (Order_number) to the rowset on the main form, so I can reference the
> main form OK
> function MyMapButton_ONLEFTDBLCLICK
>      this.parent.DropPlanner1.rowset.fields["orderNumber"].value =
> this.Order_number
> But how do I refresh the grid on the subform when I click a custom
> pushbutton on the main form.

You're running into an issue of scope. The subform is defined in the one
method, the main form doesn't know anything about it.

You can create a reference to the subform on the mainform:

function PB_Subform_onClick()
     f = this.parent.form
     set procedure to DeliveryList.wfm additive
        x = new DeliveryListForm( f, "Mypopup" )    := 10
        x.left    := 20
// create a custom property of the main form so you can
// reference the subform
f.MySubForm = x


In other code on the main form, you can then click a button, and in the
button's code:


and so on.


*Ken Mayer*
Ken's dBASE Page:
The dUFLP:
dBASE Books:
dBASE Tutorial:
dBASE Web Tutorial:
dBASE DOS to Windows Tutorial: