Super! Works perfectly!
But still doesnt work for filters which use the condition: Like
("*"+[Enter
the document number]+"*")

(
is there any way to make it work?
Lana
:
If you are using an Update query to clear the selection, I presume you
have
a Yes/No field to set. Assuming this field is called IsPicked, you
could
pick up the Filter property from your form, and use it in the WHERE
clause
of your update query.
The Click event procedure for this button would be something like
this:
Private Sub cmdSelect_Click()
Dim strSql As String
If Me.Dirty Then Me.Dirty = False 'Save first.
strSql = "UPDATE Table1 SET IsPicked = True WHERE (IsPicked =
False)"
If Me.FilterOn Then
strSql = strSql & " AND (" & Me.Filter & ")"
End If
dbEngine(0)(0).Execute strSql & ";", dbFailOnError
End Sub
Thank you Allen so much!!! You always do miracles!
I have based my report on the main table and put the button on my
form
with
your code which opens the report all right. (I use Access 2002)
My filters are Macros activated by different buttons on my form.
Your code works fine for those Macros which have pre-defined
conditions
(like "=true"). It even works fine for the conditions entered using
a
combo-box on my form.
But I have 2 Macros "Find by name" & "Find by number" which give you
a
pop-up dialogue box and you enter the value in there.
For those 2 Macros - when I press the Report button - it still
requires
to
re-enter the value rather than giving me the records which i already
see
on
the screen.
I guess I wouldnt print those kind of results much - anyway I would
have
to
look them through and check if those are what i need - while doing
so I
can
select those which i need manually using the check-box and then
print
selected.
But I got 1 more question to ask you: can i use some similar code as
you've
given me to select/de-select all the records which i view filtered?
I have only a button for deselecting everything selected (using the
Update
Query which sets value to "false" for all records in the main table)
Can you help me to create a button which would set the value to
"true"
for
only the filtered records. - I also need that for my another
project.
Anyway, thank you again for your help.
You always give simple and working solutions!
Lana
:
You can use the Filter of your form in the WhereCondition of your
OpenReport
action.
Assuming you have placed a command button on your form for "Print
as
filtered", its Event Procedure would be something like this:
Private Sub cmdPrint_Click()
Dim strWhere As String
If Me.Dirty Then Me.Dirty = False 'Save first.
If Me.FilterOn Then strWhere = Me.Filter
DoCmd.OpenReport "Report1", acViewPreview, , strWhere
End Sub
Note that in Access 2002 or 2003, it is possible for a form's
filter
to
include lookup values from combos/list boxes. If this is the case,
you
will
need to ensure that the lookup tables are in the report's
RecordSource
query, using the same names, so that the filter string resolves
correctly.