Filtering

  • Thread starter Thread starter JennKriv
  • Start date Start date
J

JennKriv

So I am just learning macros and I have a question.
I used to have my reports pull a filter from a query. Now I have things
running through macros.
What is the easiest & best way to get the filter to work with a macro.
Preferably I would like the program to grab the record I am working on but
if I can only get it to give me a popup to enter the number into that would
be fine.
 
Jenn,

Can you please give an example of what you are trying to do? Having a
report relate to a specific record would normally be done either with a
criteria in the query that the report is based on (as you seem to have
done previously), or else via the Where Condition argument of the
OpenReport action. So I am not sure of the scenario you are working with.
 
Well I have a purchase order report. What I want to have happen is that when
I hit the button to open the report I want it to bring up the report for the
record that I am on.
 
Jenn,

You would use a OpenReport action in your macro, which goes on the On
Click event property of the button. And then, in the Where Condition
argument of the OpenReport action, which you will see in the design view
of the macro, you will need to enter an expression to identify the
record. This will normally relate to the Primary Key field on the table
that the report is based on. So it may look something along these lines:
[PO_Number]=[Forms]![NameOfYourForm]![PO_Number]
Get the idea?
 
That worked great my where condition ended up being
[Purchase Orders]![P O #]=[Forms]![F-PurchaseOrders]![PONum]
Thank you so much.

Steve Schapel said:
Jenn,

You would use a OpenReport action in your macro, which goes on the On
Click event property of the button. And then, in the Where Condition
argument of the OpenReport action, which you will see in the design view
of the macro, you will need to enter an expression to identify the
record. This will normally relate to the Primary Key field on the table
that the report is based on. So it may look something along these lines:
[PO_Number]=[Forms]![NameOfYourForm]![PO_Number]
Get the idea?

--
Steve Schapel, Microsoft Access MVP
Well I have a purchase order report. What I want to have happen is that when
I hit the button to open the report I want it to bring up the report for the
record that I am on.
 
Good to know it is working well now, Jenn.

As a side note, it is not a good idea to use a # as part of the name of
a field or control.
 
Back
Top