One Type Man
One Type Man

Reputation: 11

Filtering subform by date field

Still a new learner here so please excuse my formatting.
1. I'm trying to figure out how to filter my subform[frmSelectorquerysub] based on a date range on my parent form[Results Form].
I know it can be done in VBA, that doesn't mean I know how to do it, but I want to try to use master/child fields. I've used master/child fields to filter my subform by combobox selections and I've even got it to do three filters at once off of them.
Is it possible to use this method to filter date?
I've included my (compacted/repaired) db for an example.
Please excuse the messiness.
https://drive.google.com/open?id=0B7Uh_goO6l7QSmdPLXVqQlpiQVE
2. If it's not possible to use this method I would use BETWEEN for the range, right? How about the others where they are just single values?
3. If we can get this to work this way, would someone also be able to help me fix my syntax on my master/child fields so I don't have to set all three filters that they have right now to get results?

Upvotes: 0

Views: 1964

Answers (1)

Gustav
Gustav

Reputation: 55816

MasterLinkFields and ChildLinkFields are for one or more fields only.

But you can set a filter on the subform:

Dim Filter As String

Filter = "[DateFieldInSubform] Between #" & Format(Me!StartDate.Value, "yyyy\/mm\/dd") & "# And #" & Format(Me!EndDate.Value, "yyyy\/mm\/dd") & "#"

Me!NameOfSubformControl.Form.Filter = Filter
Me!NameOfSubformControl.Form.FilterOn = True

Upvotes: 1

Related Questions