open subform no records

G

gymphil

Can anyone assist me?

I have a subform and it doesn't open if no records exist, I am trying to
change the record source of the subform by means of a command button on the
main form so that the subform will open showing different records.
I am using
Forms!ASN.ASNsubform.Form.RecordSource = "ASN2filtered"
Unfortunately because the subform didn't open in the first place I get:
"You entered an expression that has an invalid reference to the property
form / report". I know this is because the subform is still closed!! any
ideas how I can overcome this problem?
 
J

John W. Vinson

Can anyone assist me?

I have a subform and it doesn't open if no records exist, I am trying to
change the record source of the subform by means of a command button on the
main form so that the subform will open showing different records.
I am using
Forms!ASN.ASNsubform.Form.RecordSource = "ASN2filtered"
Unfortunately because the subform didn't open in the first place I get:
"You entered an expression that has an invalid reference to the property
form / report". I know this is because the subform is still closed!! any
ideas how I can overcome this problem?

Well... a Subform isn't "opened" in the usual sense. The mainform has a
Subform control, which contains a form; when you open the main form, the
subform opens (first, actually) without any code or step involved.

Is ASNsubform the Name property of the *Subform Control* on the mainform? The
name of the form object within the subform control is irrelevant and not used.
If the code exists on the form named ASN, and the Subform Control's name is in
fact ASNsubform, you should be able to use

Me!ASNsubform.Form.Recordsource = "ASN2filtered"
 

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