K
keith.rocheck
Hey,
I am working on a database for my campus television station. One of
the sections is related to Show Tapes and the Episodes that are
contained within them.
I am trying to perform a custom filter on a sub-form using VBA when the
error in the title pops up. There are three fields associated with
this custom filter: ShowTitle, LowerDate, and UpperDate.
The routine looks to make sure two dates are entered or none then picks
whether to filter just the ShowTitle, just dates or both (or cancel the
filter).
The error shows up on any of the: "Me.ShowTapesQuery.Form.Filter = ..."
lines.
Any ideas on how to solve this are greatly appreciated.
Private Sub ApplyFilterButton_Click()
On Error GoTo Err_ApplyFilterButton_Click
If Me.ApplyFilterButton.Caption = "Apply Filter" Then
If Not (Me.LowerDate = "" And Me.UpperDate = "") Then
If Not Me.LowerDate = "" And Not Me.UpperDate = "" Then
Else
MsgBox "You must enter both dates before applying the
filter!"
GoTo Exit_ApplyFilterButton_Click
End If
End If
If Not Me.ShowTitle = "" And Not Me.UpperDate = "" Then
Me.ShowTapesQuery.Form.Filter = "ShowTapes.Show = " &
Me.ShowTitle.Value & " And ShowTapeSlots.Date > #" & Me.LowerDate.Value
& "# And ShowTapeSlots.Date < #" & Me.UpperDate.Value & "#"
Me.ShowTapesQuery.Form.FilterOn = True
Me.ShowTitle.Enabled = False
Me.LowerDate.Enabled = False
Me.UpperDate.Enabled = False
Me.ApplyFilterButton.Caption = "Cancel Filter"
Else
If Not Me.ShowTitle = "" Then
Me.ShowTapesQuery.Form.Filter = "ShowTapes.Show = " &
Me.ShowTitle.Value
Me.ShowTapesQuery.Form.FilterOn = True
Me.ShowTitle.Enabled = False
Me.LowerDate.Enabled = False
Me.UpperDate.Enabled = False
Me.ApplyFilterButton.Caption = "Cancel Filter"
Else
If Not Me.LowerDate = "" Then
Me.ShowTapesQuery.Form.Filter = "ShowTapeSlots.Date
Me.ShowTitle.Enabled = False
Me.LowerDate.Enabled = False
Me.UpperDate.Enabled = False
Me.ApplyFilterButton.Caption = "Cancel Filter"
End If
End If
End If
Else
Me.ShowTapes.Form.FilterOn = False
Me.ShowTitle.Enabled = True
Me.LowerDate.Enabled = True
Me.UpperDate.Enabled = True
Me.ApplyFilterButton.Caption = "Apply Filter"
End If
Exit_ApplyFilterButton_Click:
Exit Sub
Err_ApplyFilterButton_Click:
MsgBox Err.Description
Resume Exit_ApplyFilterButton_Click
End Sub
Keith
I am working on a database for my campus television station. One of
the sections is related to Show Tapes and the Episodes that are
contained within them.
I am trying to perform a custom filter on a sub-form using VBA when the
error in the title pops up. There are three fields associated with
this custom filter: ShowTitle, LowerDate, and UpperDate.
The routine looks to make sure two dates are entered or none then picks
whether to filter just the ShowTitle, just dates or both (or cancel the
filter).
The error shows up on any of the: "Me.ShowTapesQuery.Form.Filter = ..."
lines.
Any ideas on how to solve this are greatly appreciated.
Private Sub ApplyFilterButton_Click()
On Error GoTo Err_ApplyFilterButton_Click
If Me.ApplyFilterButton.Caption = "Apply Filter" Then
If Not (Me.LowerDate = "" And Me.UpperDate = "") Then
If Not Me.LowerDate = "" And Not Me.UpperDate = "" Then
Else
MsgBox "You must enter both dates before applying the
filter!"
GoTo Exit_ApplyFilterButton_Click
End If
End If
If Not Me.ShowTitle = "" And Not Me.UpperDate = "" Then
Me.ShowTapesQuery.Form.Filter = "ShowTapes.Show = " &
Me.ShowTitle.Value & " And ShowTapeSlots.Date > #" & Me.LowerDate.Value
& "# And ShowTapeSlots.Date < #" & Me.UpperDate.Value & "#"
Me.ShowTapesQuery.Form.FilterOn = True
Me.ShowTitle.Enabled = False
Me.LowerDate.Enabled = False
Me.UpperDate.Enabled = False
Me.ApplyFilterButton.Caption = "Cancel Filter"
Else
If Not Me.ShowTitle = "" Then
Me.ShowTapesQuery.Form.Filter = "ShowTapes.Show = " &
Me.ShowTitle.Value
Me.ShowTapesQuery.Form.FilterOn = True
Me.ShowTitle.Enabled = False
Me.LowerDate.Enabled = False
Me.UpperDate.Enabled = False
Me.ApplyFilterButton.Caption = "Cancel Filter"
Else
If Not Me.LowerDate = "" Then
Me.ShowTapesQuery.Form.Filter = "ShowTapeSlots.Date
Me.ShowTapesQuery.Form.FilterOn = True#" & Me.LowerDate.Value & "# And ShowTapeSlots.Date < #" & Me.UpperDate.Value & "#"
Me.ShowTitle.Enabled = False
Me.LowerDate.Enabled = False
Me.UpperDate.Enabled = False
Me.ApplyFilterButton.Caption = "Cancel Filter"
End If
End If
End If
Else
Me.ShowTapes.Form.FilterOn = False
Me.ShowTitle.Enabled = True
Me.LowerDate.Enabled = True
Me.UpperDate.Enabled = True
Me.ApplyFilterButton.Caption = "Apply Filter"
End If
Exit_ApplyFilterButton_Click:
Exit Sub
Err_ApplyFilterButton_Click:
MsgBox Err.Description
Resume Exit_ApplyFilterButton_Click
End Sub
Keith