doug, sorry about the delay in responding but i'd guess your response came
'after hours'; anyway, i subbed your code for the other one and found i
needed to explicity set .FilterOn = true in the Else part of the if
clause;
with that out of the way, i am still getting the parameter query. i
thought
i'd check the properties of the "Screening Log (Edit Only)" mainform we're
talking about afterwards and found the following string in the filter
property:
[Forms]![Screeing Log (Edit
Only)]![DaysView].[Form]![Date_Of_Visit]<=Date()
i suspect this has something to do with the fact there's a "DaysView"
child
subform on this mainform which had data i am filtering via a cmd button i
created on the main one, the code behind which is as follows:
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()" ' <-----NOTE THIS LINE
HERER
.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.Add_Record.Visible = False
Me.NavigationButtons = False
Else
Me.FilterLbl.Visible = False
Me.Close.Visible = True
Me.Add_Record.Visible = True
Me.NavigationButtons = True
End If
Exit_FilterDates_Click:
Exit Sub
Err_FilterDates_Click:
MsgBox Err.description
Resume Exit_FilterDates_Click
End Sub
since i count myself a newbie in these arcane matters, i guess that even
though i'm not 'activating' the filter dates cmdbutton when i click the
fltCRA button that the date filter is getting stuffed into the filtering
role
or something. this seems kind of an impossibility and i may need to
rethink
the approach.
best,
-ted
Douglas J. Steele said:
See whether the following works:
Private Sub fltCRA_AfterUpdate()
If Me.fltCRA = "<All>" Then
Me.Filter = vbNullString
Me.FilterOn = False
Else
Me.Filter = "[CRA] = '" & Me![fltCRA] & "'"
Me.FilterOn
End If
End Sub
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
doug and kevin (in alphabetic order), the adjusted (per your astute
ophthalmological observations) i'm using is as follows:
Private Sub fltCRA_AfterUpdate()
If Me.fltCRA = "<All>" Then
DoCmd.ShowAllRecords
Else
DoCmd.ApplyFilter , "[CRA] = '" & Me![fltCRA] & "'"
End If
End Sub
what's happening now is that i'm seeing a window titled "Enter
Parameter
Value" requesting a value for
Forms!Screening Log (Edit
which almost looks as though it's truncated ("Screening Log (Edit
Only)"
is
the form's name).
so, i guess i'm almost back where i began.
-ted
ps: CRA is a text field in the query underlying "Screening Log (Edit
Only)"
:
The line:
DoCmd.ApplyFilter , "[CRA] = ' " & Me![fltCRA] & " ' "
includes a space character before and after the filtered value. Not
surprisingly, none of your records match this exact pattern. Someone
may
have included these spaces for code readability *in the newsgroup*,
but
you need to actually code:
DoCmd.ApplyFilter , "[CRA] = '" & Me![fltCRA] & "'"
This assumes that "CRA" is the name of a text field in the underlying
table. If it is a numeric field, drop the apostrophes altogether.
HTH,
Kevin
Ted wrote:
according to my best guesstimations the VBA code (in a2k app'n)
should
serve
to filter those records meeting the criterion
Private Sub fltCRA_AfterUpdate()
If Me.fltCRA = "<All>" Then
DoCmd.ShowAllRecords
Else
DoCmd.ApplyFilter , "[CRA] = ' " & Me![fltCRA] & " ' "
End If
End Sub
the "fltCRA" unbound combobox is in the form header of my form named
"Screening Log (Edit Only)" and it uses as its row source the query
named
lkpFormCRA (in SQL):
SELECT DISTINCT [Screening Log].CRA FROM [Screening Log] UNION
SELECT
"<All>" FROM [Screening Log];
my reason for writing is because of the unexpected behavior which
ensues
when i select one of the values (other than '<All>') in the
combobox.....i.e.
there are no records selected, there are no controls appearing in
the
details
section of the form, and the controls which are in the form header
section
(fltCRA, LastName, FirstName and MI) are all blank??!!!?
anyone have a theory as to what's up with that?
-ted