In your case, it seems to me since you have the names of the orchards, you would have a combo on the mainform whose
rowsource was the names of the Orchards.
The subform contains all data from your table you need including orchard name. That is it's recordsource is - Let's assume for this post it is - SELECT * from MyOrchardTable
In the afterUpdate event of the combo (after you select the value you want) you would have code along my set up below.
The sql for your subform record source will get modified based on the combo value selected on the mainform.
This is from a sample I created for a different post which shows the general set up:
Code:
Private Sub txtFilter_AfterUpdate()
'
' This sample contain information about Animals and where they were seen (Lat/Long) and when.
' The subform is linked to mainform on AnimalID
' In my sample I used a textbox as the filter to allow entry of any part or no keyword/string by using the like operator
Dim sql As String
'This is the sql that serves as recordsource for my subform
sql = "SELECT aname, [AnimalLocs].[SightingDate], [AnimalLocs].[GPSLong], " _
& "[AnimalLocs].[GPSLat] " _
& " FROM [AnimalLocs] Inner join Animal " _
& " ON [AnimalLocs].[AnimalId] = Animal.animalid " _
& " Where aname like '*" & Me.txtFilter & "*' "
' these next two lines are the guts of the filter, and the syntax says
' on me (mainform) using the AnimalLocsSubform control, which is a Form, set its recordsource =
' 1 - sets the subform recordsource
Me.AnimalLocsSubform.Form.RecordSource = sql
' 2 - tells Access to requery the subform
Me.AnimalLocsSubform.Form.Requery
End Sub
To repeat:
In your case, it seems to me since you have the names of the orchards, you would have a combo on the mainform whose
rowsource is the unique names of the Orchards.
eg: Select distinct OrchardName from myOrchardTable
The subform contains all data from your table you need including orchard name. That is it's recordsource is - Let's assume for this post it is - SELECT * from MyOrchardTable
So your
Private Sub cboFilter_AfterUpdate()
Dim sql As String
sql = "SELECT * from MyOrchardTable " _
& " where orchardname = '" & me.cboFilter &"' "
and your 2 critical statements would be similar to mine, but using your subform control name
and your name for the combo.
There is a youtube video by Steve Bishop --he shows a keyword search with Form/subform and filter.
He then requeries the sub form to use the textbox entry on the mainform as the new recordsource of the subform. You should watch this to get all the details.
Good luck with your project.