T
Ted
i use the following vba code in a button on the mainform ("Screening Log
(Review Only)" in my a2k application:
Private Sub FilterDates_Click()
On Error GoTo Err_FilterDates_Click
With Me.[DaysView].Form
If .FilterOn Then
..FilterOn = False 'Turn the filter off.
lngGreen = RGB(0, 150, 0)
Me.FilterDates.ForeColor = lngGreen
Else
..Filter = "[DateOfVisit] >= Date()"
..FilterOn = True
lngRed = RGB(225, 0, 0)
Me.FilterDates.ForeColor = lngRed
End If
End With
If Me.FilterDates.ForeColor = lngRed Then
Me.FilterLbl.Visible = True
Me.Close.Visible = False
Me.NavigationButtons = False
Else
Me.FilterLbl.Visible = False
Me.Close.Visible = True
Me.NavigationButtons = True
End If
Exit_FilterDates_Click:
Exit Sub
Err_FilterDates_Click:
MsgBox Err.description
Resume Exit_FilterDates_Click
End Sub
the button is intended to limit the user's ability to view records in a
nested/child subform (called 'DaysView') which had 'DateOfVisit' earlier than
"today's", or to put it another way, the intent is to view only records in
'DaysView' dated "today" and after. the rest is pretty much "there" for the
interested reader to see for himself.
the point of this posting is attributable to what i feel is a quirky way
that the applcation behaves when you click the filter button a 2nd time, i.e.
to REMOVE the filter from the 'DaysView' subform. what i mean by that is that
even if your cursor is positioned on a control in the subform, when you
'unfilter' it, the next thing the user sees is that he's been transported to
the first control on the "Screening Log (Review Only)" main form and that the
main form is displaying the first record in the database's data. this is kind
of a hassle for the user, since, he or she needs to manually locate the
appropriate record in the database in order to be able to view its subform's
data. does this make sense? does it have some way to shortcircuit that
behavior? the filter seems to work just fine when the user clicks the
cmdbutton the first time (i.e. to activate it).
the elements that go into making the PK of the “DaysView†underlying table’s
(which is also named ‘DaysView’) are
“Last Name†(text), “First Name†(text) , “MI†(text) , “MR_Numberâ€
(number), “IRB Number†(text), and “RecordNumber†(number). The names of the
said control sources on the subform are (respectively): “LastNameâ€,
“First_Nameâ€,â€M_Iâ€,â€MRNumberâ€,â€IRBNumberâ€,and lastly â€Visitâ€
thanks in advance,
-ted
(Review Only)" in my a2k application:
Private Sub FilterDates_Click()
On Error GoTo Err_FilterDates_Click
With Me.[DaysView].Form
If .FilterOn Then
..FilterOn = False 'Turn the filter off.
lngGreen = RGB(0, 150, 0)
Me.FilterDates.ForeColor = lngGreen
Else
..Filter = "[DateOfVisit] >= Date()"
..FilterOn = True
lngRed = RGB(225, 0, 0)
Me.FilterDates.ForeColor = lngRed
End If
End With
If Me.FilterDates.ForeColor = lngRed Then
Me.FilterLbl.Visible = True
Me.Close.Visible = False
Me.NavigationButtons = False
Else
Me.FilterLbl.Visible = False
Me.Close.Visible = True
Me.NavigationButtons = True
End If
Exit_FilterDates_Click:
Exit Sub
Err_FilterDates_Click:
MsgBox Err.description
Resume Exit_FilterDates_Click
End Sub
the button is intended to limit the user's ability to view records in a
nested/child subform (called 'DaysView') which had 'DateOfVisit' earlier than
"today's", or to put it another way, the intent is to view only records in
'DaysView' dated "today" and after. the rest is pretty much "there" for the
interested reader to see for himself.
the point of this posting is attributable to what i feel is a quirky way
that the applcation behaves when you click the filter button a 2nd time, i.e.
to REMOVE the filter from the 'DaysView' subform. what i mean by that is that
even if your cursor is positioned on a control in the subform, when you
'unfilter' it, the next thing the user sees is that he's been transported to
the first control on the "Screening Log (Review Only)" main form and that the
main form is displaying the first record in the database's data. this is kind
of a hassle for the user, since, he or she needs to manually locate the
appropriate record in the database in order to be able to view its subform's
data. does this make sense? does it have some way to shortcircuit that
behavior? the filter seems to work just fine when the user clicks the
cmdbutton the first time (i.e. to activate it).
the elements that go into making the PK of the “DaysView†underlying table’s
(which is also named ‘DaysView’) are
“Last Name†(text), “First Name†(text) , “MI†(text) , “MR_Numberâ€
(number), “IRB Number†(text), and “RecordNumber†(number). The names of the
said control sources on the subform are (respectively): “LastNameâ€,
“First_Nameâ€,â€M_Iâ€,â€MRNumberâ€,â€IRBNumberâ€,and lastly â€Visitâ€
thanks in advance,
-ted