Filter OUT Data....... in Macro Condition

G

Guest

I need to be able to output [many] reports using the "OutputTo" Macro. (But
only one record at a time!!)
So for each line in the macro, I need to FILTER out all records, EXCEPT THE
ONE RECORD that is stated.

The data field for example has something like "underwater_1", so it can be
used in the reports: underwater_1_120.jpg underwater_1_300.jpg etc.
(using text like "_120.jpg" and "_300.jpg" etc. in the report)

The exact Form/Field name/address of where that is:
Forms![Files_Topics Query1]![displayfile1]="underwater_1"

So..... What do I need to put in the CONDITION of the macro, to FILTER out
all files, EXCEPT THE ONE that is stated in that Condition?


Thanks Greatfully for your assistance!!! :)
 
T

tina

macro Conditions don't work like that. a Condition is used to determine
whether or not to carry out a specific macro Action - but the Condition has
no effect on *how* the action itself is carried out.

you can add a VBA event procedure to the report's Open event, to set the
report's Filter property and turn it on. when you run the Output macro
action that calls the report, the report's Open event will run and filter
the records returned in the report.

hth
 
G

Guest

Sorry to sound stupid, but where do we even start for that VBA event
procedure? And how complicated is it for someone like me that is very basic?
In other words.... is it easy enough for me to do?

Thanks for your effort Tina!! :)
 
T

tina

setting the Filter property of a report (or form) in VBA requires writing a
"criteria" expression like you would use in a query, but without the WHERE.
for example, say you have a table listing the names of people, FirstName and
LastName fields. and you build a report based on the People table. now you
want the user to be able to enter a particular first name in a textbox in a
form and then click a command button to output that report showing records
only for people with that first name. i'll call the form "frmOutput" and the
textbox control "txtFirstName".

so you'd set the Filter and FilterOn properties of the report, in the
report's Open event procedure, as

Me.Filter = "FirstName = '" & Forms!frmOutput!txtFirstName & "'"
Me.FilterOn = True

note that the above is the syntax for a Text data type. if the field you're
filtering on is a Number data type, the syntax would be

Me.Filter = "NumberField = " & Forms!frmOutput!txtNumber

if the field you're filtering on is a Date/Time data type, the syntax would
be

Me.Filter = "DateField = #" & Forms!frmOutput!txtDate & "#"

if you don't know how to create an event procedure, see "Create a VBA event
procedure" at http://home.att.net/~california.db/downloads.html for
illustrated instructions.

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top