How can I refresh a subform's recordsource?

D

Dave

I have a subform displayed in continuous forms that I need to refresh from
the parent form.

I can refresh controls on a subform as:

Me.f_Note_sub.Form![cboNationID].Requery

But when I try to refresh a subform recordsource as

Me.f_Person_sub.Form!RecordSource.Requery

I get an error that Access does not recognize "RecordSource"

Can anyone help me with the syntax to refresh a subform's recordsource?
 
P

Penguin

Try this code:

Dim MyControl As Control
Set MyControl = Forms!FormName!ControlName
MyControl.Requery

Replace FormName for your main form name and ControlName for the name
of the subform control on the main form.

Hope this helps.
 
M

Marshall Barton

Dave said:
I have a subform displayed in continuous forms that I need to refresh from
the parent form.

I can refresh controls on a subform as:

Me.f_Note_sub.Form![cboNationID].Requery

But when I try to refresh a subform recordsource as

Me.f_Person_sub.Form!RecordSource.Requery

I get an error that Access does not recognize "RecordSource"

The !RecordSource is inappropriate. Just use:

Me.f_Person_sub.Form.Requery
 
D

Dave

Thanks guys


Marshall Barton said:
Dave said:
I have a subform displayed in continuous forms that I need to refresh from
the parent form.

I can refresh controls on a subform as:

Me.f_Note_sub.Form![cboNationID].Requery

But when I try to refresh a subform recordsource as

Me.f_Person_sub.Form!RecordSource.Requery

I get an error that Access does not recognize "RecordSource"

The !RecordSource is inappropriate. Just use:

Me.f_Person_sub.Form.Requery
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top