Changing ResordSource of subform (1 Viewer)

Help.Chris

Registered User.
Local time
Today, 20:01
Joined
Oct 11, 2000
Messages
43
Hi Everyone,

Please help with this small problem if you can.

I would like to change the RecordSource of a SubForm, from a toggle selection in a master form. I know you can use Me.RecordSource = "" from within the subform, but does anyone know a command that can accomplish the same thing from the master form. It does not seem to like it if I use the exact name of the form, ie. Forms![Name1]![Name2].

Thanks for any help.

Chris
 

llkhoutx

Registered User.
Local time
Today, 14:01
Joined
Feb 26, 2001
Messages
4,018
Use the expression builder to build the name you need.
 

Help.Chris

Registered User.
Local time
Today, 20:01
Joined
Oct 11, 2000
Messages
43
I have just tried this, and i can not get it to run.

The record source of the form is changing between two queries, the expression builder lets me select fields of the query, but not change the recordsource of the form between the two queries.

How can I do this?? Please help

Thanks

Chris
 

bob makepeace

Registered User.
Local time
Today, 20:01
Joined
Aug 18, 2000
Messages
32
Hi,

The syntax to refer to a subform is:-

Forms!mainform.Form!subform!field

so to set the recordsource it would be

forms!mainform.form!subform!recordsource ="query"

cheers

bob

[This message has been edited by bob makepeace (edited 03-15-2001).]
 

Help.Chris

Registered User.
Local time
Today, 20:01
Joined
Oct 11, 2000
Messages
43
I am not trying to change the recordsource of a field though, I am trying to change it for a complete form. This can be done from within the form to be changed, using Me!recordsource="Select * from blah blah", so can be changed at runtime. I need to be able to change from the main form though not the subform. when trying to use the Forms![form]![recordsource]="" approach though Access says it cannot find FIELD [Sumform].

If I have the code in the subform, I need to be able to rerun this code each time the controls are changed in the master form. the requery method on the controls does not work.
I am about to try repaint and refresh.

If anyone has any suggestions it would be greatly appreciated.

Chris
 

Alexandre

Registered User.
Local time
Tomorrow, 02:01
Joined
Feb 22, 2001
Messages
794
Try: Forms![FormName].recordsource = ...

Hope this helps
 

bob makepeace

Registered User.
Local time
Today, 20:01
Joined
Aug 18, 2000
Messages
32
Hi,

I thought you wanted to change the recordsource of the "whole" subform.

You can reference the subform controlsource
from the master form using this code.

forms!mainform.form!subform!recordsource ="query"

You can populate it with SQL or just
a query name as above.

bob

[This message has been edited by bob makepeace (edited 03-15-2001).]
 

Users who are viewing this thread

Top Bottom