Need help with WHERE

G

Guest

Hi there! Using A02 on XP. Not a programmer but learning VB and loving it.
Have a query with a report that sorts the output by [ContractNumber].
Someone would love to be able to run the same report, same data (same query)
BUT they would love to have the output sorted by [PlanType]. I've read a bit
about filters and know how to click into a field on a form and apply a filter
but don't know how to have 2 buttons, 1 to run the rpt sort one way, the
other to run the rpt sort another way but by using the same report and query.
Is this possible? Am I on track here? I've seen in macros where you can
run a filter but you have to have a query to name and a WHERE condition.
Would like to use the base query and utilize the WHERE statement. Not sure
which way to go here. Trying to avoid having multiple instances of queries
and reports when the only difference is the WHERE.

Thanks in advance for any help or advice on this.
 
G

Guest

Try sending a different OpenArgs in the Report open command line
docmd.OpenReport "ReportName",,,,,"PlanType"

On the Report OnOpen event run the code that check the OpenArgs and set the
order by

Me.OrderBy = Me.OpenArgs
Me.OrderByOn = True

I haven't tried it, but I hope it will help you
 

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