K
Katherine
Hello,
I've been working on filtering a form based on data contained in a
subform. I got some code from Allen Browne's site
(http://allenbrowne.com/tips.html), but I haven't been able to get it
to do exactly what I need yet.
Here's the code I have right now:
Private Sub Combo3272_AfterUpdate()
Dim strSQL As String
If IsNull(Me.Combo3272) Then
Me.RecordSource = "EventDonationCalTotals"
Forms![Mailing List Form].RecordSource = "MailingListQuery"
Else
strSQL = "SELECT DISTINCTROW EventDonationCalTotals.* FROM
EventDonationCalTotals " & _
"INNER JOIN MailingList ON " & _
"EventDonationCalTotals.MailingListID =
MailingList.MailingListID " & _
"WHERE EventDonationCalTotals.Total = " & Me.Combo3272 & ";"
Me.RecordSource = strSQL
End If
End Sub
When I enter something into the combo box, it will filter the records
accordingly in the subform, and will lower the number of records found
based on how many meet the criteria I entered. However, while it
populates the subform with the right data, it does not populate the
main form with the corresponding data. The main form just displays
"#Name?" in every field. When I remove the filtering criteria, both
forms go back to being populated with the correct information.
What code can I add to have the main form populated with the correct
info when the filter is on? I've tried a few things, but with no luck
so far. Any suggestions?
Thanks!
Katherine
I've been working on filtering a form based on data contained in a
subform. I got some code from Allen Browne's site
(http://allenbrowne.com/tips.html), but I haven't been able to get it
to do exactly what I need yet.
Here's the code I have right now:
Private Sub Combo3272_AfterUpdate()
Dim strSQL As String
If IsNull(Me.Combo3272) Then
Me.RecordSource = "EventDonationCalTotals"
Forms![Mailing List Form].RecordSource = "MailingListQuery"
Else
strSQL = "SELECT DISTINCTROW EventDonationCalTotals.* FROM
EventDonationCalTotals " & _
"INNER JOIN MailingList ON " & _
"EventDonationCalTotals.MailingListID =
MailingList.MailingListID " & _
"WHERE EventDonationCalTotals.Total = " & Me.Combo3272 & ";"
Me.RecordSource = strSQL
End If
End Sub
When I enter something into the combo box, it will filter the records
accordingly in the subform, and will lower the number of records found
based on how many meet the criteria I entered. However, while it
populates the subform with the right data, it does not populate the
main form with the corresponding data. The main form just displays
"#Name?" in every field. When I remove the filtering criteria, both
forms go back to being populated with the correct information.
What code can I add to have the main form populated with the correct
info when the filter is on? I've tried a few things, but with no luck
so far. Any suggestions?
Thanks!
Katherine