=> Refresh a subform

  • Thread starter Thread starter Rhonda Fischer
  • Start date Start date
R

Rhonda Fischer

Hello,

I have tried:

=> Forms!frmOrder!frmOrderDetail.Requery
=> Me!frmOrderDetail.Requery
=> Forms!frmOrder.Controls(1).Requery

None of which seem to work for me.

I notice in the VB project panel no subforms are
displayed, but there must be some means of refreshing
them without closing the entire form.

Thank you for any ideas you might have.

Cheerio
Rhonda
 
The general syntax is:

Me.subControlName.Requery
or
Forms!MainformName!subControlName.Requery

Often the problem is a misunderstanding of which name to use for the
subform. You want to use the name of the Subform Control on the main form
and not the actual name of the subform.
 
Rhonda Fischer said:
Hello,

I have tried:

=> Forms!frmOrder!frmOrderDetail.Requery
=> Me!frmOrderDetail.Requery
=> Forms!frmOrder.Controls(1).Requery

None of which seem to work for me.

I notice in the VB project panel no subforms are
displayed, but there must be some means of refreshing
them without closing the entire form.

Thank you for any ideas you might have.

Cheerio
Rhonda

You don't say what error messages, if any, these attempts give you.
That would help.

Where is the code running? Behind the main form, or behind the subform,
or in a standard module? If the code is to run behind the subform
itself, then all you need is

Me.Requery

If the code is running any place else -- behind the main form, or in a
standard module, or even behind some other form -- you have to make sure
you use the name of the subform *control* on the main form, which may or
may not be the name of the form object that control is displaying. Open
the main form in design view, click once on the subform control, and
open its property sheet to verify the actual name of the control. If
the name of the subform control is actually "frmOrderDetail", then one
(or both) of these lines ought to have worked:

Forms!frmOrder!frmOrderDetail.Requery
Me!frmOrderDetail.Requery

But if the subform control is actually named, say, "Child1", then the
lines would have to be like this:

Forms!frmOrder!Child1.Requery
Me!Child1.Requery

By the way, your subject says "Refresh" but your code says "Requery".
Be aware that Refresh and Requery are different methods with different
results. I'm assuming you really want to requery the subform, not just
refresh it.
 
Back
Top