Filter in Subform

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

Hi Wizards,
Here is my question. Can I filter the records on subform
or the only message I will get:
"impossible...because the form or report isn't bound to
the table or query"?

I have the form with dates on the calendar and subform
with the date corresponding to some particular date.These
two forms (main and sub) do not have any bounded fields.
I would like to click on the date on the form and see all
corresponding data for that particular date displayed on
subform. What I have done:
(FilterforSubform - is the field for filtering;
PickupDate - the field in subform for filtering)

Me!FilterforSubform = Date
DoCmd.GoToControl "sub_Calendar"
DoCmd.ApplyFilter , "PickupDate" = Forms!frmCalendarLV!
FilterforSubform
DoCmd.RepaintObject acForm, "frmCalendarLV"

I keep getting the message above:'The action or method is
invalid because..the form or report isn't bound to the
table or query'.
Note: subform is bounded to the table.

Your help, Wizards, will be very much appreciated..
Thank you.
 
I'm not sure I follow your logic here but I guess what is probably happening
is that the applyfilter command is running in the form and not the subform.
To test this after you run this docmd.applyfilter, check the Filter property
in the parent form.

If thats the case you can run something like
subform2.application.docmd.applyfilter ....

Hope that helps.
 
The date needs to be concatenated into the string to use as a filter:

Dim strFilter As String
If IsDate(Me.FilterForSubform) Then
With Me.sub_Calendar.Form
strFilter = "PickupDate = " Format(Me.FilterForSubform,
"\#mm\/dd\/yyyy\#")
Me.Filter = strFilter
Me.FilterOn = True
End With
Else
MsgBox "Enter a date"
End If
 
Back
Top