Referring to a subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with 2 subforms. I am trying to set the record source of the
2nd subform from the current event of the 1st, so that only the related
records show in the 2nd subform. Please note that I cannot use a sub on a
sub, as it does not fit on my main form and my user wants it all on one form.

I've been using these lines of code in the current event of my 1st subform,
which generate the error 2450: "can't find the form
'sfrmLCCGPAdvancementPayments' referred to in a macro expression or Visual
Basic Code."

Forms!sfrmLCCGPAdvancementPayments.RecordSource = WhichLCCGPSource

Forms!sfrmLCCGPAdvancementPayments.Requery

Also,

Forms("frmLCCGP").Form("sfrmLCCGPAdvancementPayments").RecordSource =
WhichLCCGPSource

generates the error 438: Object doesn't support this property or method.
However,

Forms("frmLCCGP").Form("sfrmLCCGPAdvancementPayments").Visible = False

works.

Here's the kicker... This was working at one point. I could click through
the records in my 1st subform and the records in the 2nd would filter. Now it
doesn't work. I only made some minor changes in code to other areas since I
last tested. I went back in and commented out all that code and I still can't
get this to work. I have also tried 2 or 3 other forms of syntax and still
get errors.

Can someone tell me how to set the record source of 1 subform from another
subform? I'm sure it's just a matter of syntax.

Thanks,
Clint
 
cherman said:
I have a form with 2 subforms. I am trying to set the record source of the
2nd subform from the current event of the 1st, so that only the related
records show in the 2nd subform. Please note that I cannot use a sub on a
sub, as it does not fit on my main form and my user wants it all on one form.

I've been using these lines of code in the current event of my 1st subform,
which generate the error 2450: "can't find the form
'sfrmLCCGPAdvancementPayments' referred to in a macro expression or Visual
Basic Code."

Forms!sfrmLCCGPAdvancementPayments.RecordSource = WhichLCCGPSource

Forms!sfrmLCCGPAdvancementPayments.Requery

Also,

Forms("frmLCCGP").Form("sfrmLCCGPAdvancementPayments").RecordSource =
WhichLCCGPSource

generates the error 438: Object doesn't support this property or method.
However,

Forms("frmLCCGP").Form("sfrmLCCGPAdvancementPayments").Visible = False

works.


I don't know why any of those ever worked.

Try this:
Forms!frmLCCGP.sfrmLCCGPAdvancementPayments.FORM.RecordSource
= WhichLCCGPSource

Note that setting the RecordSource property automatically
requeries the form, so don't waste the time doing the
requery.
 
Back
Top