Filtering Subforms

Joined
May 1, 2006
Messages
2
Reaction score
0
I have two tables:
- Horses
- Records

Linked together by a relationship one(horse)-to-many(records).

A form called 'frmRecordsByHorse' has the fields:
- HorseID
- HorseName
- Picture

Made from the Horse table.

Below this is a subform called 'frmRecords_Subform.'
It has the fields:
- RecordID
- TaskDate
- TaskID
- TaskName

Made from the Records table.

The table for Records has a field called Horse ID....the link!

The form is set up so you can navigate through the horses and the subform displays all the Records (which are daily tasks) that have happened for that horse.

I am wanting to have buttons on the subfrom that allows you to:
- Show Current Months Records
- Show This Weeks Records
- Show Today's Records
- Show All Records

By editting the subform, I generated a series of buttons which perform this Event Procedures:
Private Sub ShowMonth_Click()
filter = ""
DoCmd.ApplyFilter , "Year([TaskDate]) = Year(Now()) And Month([TaskDate]) = Month(Now())"
End Sub

These all work perfectly when you open ONLY the subform in Design View.

HOWEVER - if I open the 'frmRecordsByHorse' form (main with subform) and click one of these buttons (they are inside the subform at the moment)......
It brings up an Enter Parameter box for [TaskDate].

I found online something which recommended changing the code to:
Private Sub ShowToday_Click()
filter = ""
With Me.frmRecords_Subform.Form
.filter = "TaskDate = Date()"
.FilterOn = True
End With
End Sub

But this brings up an compile error: member of data member not found.

Any suggestions/solutions?

(sorry this is long, i wanted to explain it properly)
 
Back
Top