Cross-form communications

  • Thread starter Thread starter Bill Stanton
  • Start date Start date
B

Bill Stanton

I have a form with two sub-forms. In the code-sheet
of one of the sub-forms, how do I trigger a Requery
in the other sub-form. The following type of statements
don't work, but am I close?

forms!formname!filter = filter-expression
forms!formname.requery

Thanks,
Bill
 
You would reference subformB through the parent of subformA

From SubformA:

me.parent.subformB.filter = strFilter
me.parent.subformB.requery

Where SubformB is the name of the second subform control on the parent form.
 
Forms!NameOfMainForm!NameOfSubform.Form.Requery


--
PC Datasheet
A Resource for Access, Excel and Word Applications
(e-mail address removed)
www.pcdatasheet.com

· Design and basic development for new applications
· Additions, Modifications and "Fixes" for existing applications
· Mentoring for do-it-yourselfers who want guidance
· Complete application design and development
· Applications Using Palm Pilot To Collect Data And
Synchronize The Data Back To Access Or Excel
 
From the code-sheet of 1st sub-form:

Private Sub Form_Click()
If Me.Parent.Name = "DonationEntry" Then
Forms!DonationEntry.Form!CurrentName.Caption = Me.FamilyName
' Me.Parent.DonationsSubform.Filter = "FamilyID = " & Me.FamilyID
' Me.Parent.DonationsSubform.Requery

Forms!DonationEntry!DonationsSubform.Form.Filter = "FamilyID = " &
Me.FamilyID
Forms!DonationEntry!DonationsSubform.Form.Requery
End If

End Sub

The main form is "DonationEntry" and the 2nd of the two sub-forms is
"DonationsSubform". As you can infer from what you see, I tried both
types of syntax. As you see paired or individually, I get a 2465 error.

Did I not understand what you've suggested?

Thanks,
Bill
 
Bill,

Please explain what you are trying to do in your code and please provide the
text of the 2465 error.

Steve
PC Datasheet
 
Steve,
I have a main form and two sub-forms. The first sub-form
is displaying a list of names from a table of families. The
second sub-form is displaying an array of dates and values
from a table that is normalized to the list in the fist sub-form.
When a name is selected in the first sub-form, the primary
key for its underlying RecordSource is used to specify
a filter for the second sub-form followed by a Requery for
the 2nd sub-form.

I get a 2465 with both types of statements posted earlier.
Using the Me.Parent.... form, the message text is "Application
defined or object define error". Using the Forms!... form,
the message text is "Can't find the field "DonationsSubform
referred to in your expression".

Hope this explains things a little better.

Thanks,
Bill
 
<<Using the Forms!... form, the message text is "Can't find the field
"DonationsSubform
referred to in your expression". >>

Forms!DonationEntry!DonationsSubform.Form.Filter = "FamilyID = " & Me.FamilyID
Forms!DonationEntry!DonationsSubform.Form.Requery

Open your DonationEntry form in design view. Select the subform control that
holds your Donations subform. Open properties, go to the Other tab and name the
control DonationsSubform.

Steve
PC Datasheet
 
I'm embarrassed! I thought I'd checked that, but didn't notice
there was a blank between "Donations" and "Subform".

Thanks for waking me up!

Bill
 
Back
Top