filtering a report via a pop-up

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to filter an accounting report via a pop-up. I have sample from the
knowledge base that is almost perfect:

http://support.microsoft.com/kb/q147143/

However, I also need to filter for a range of values such as date or check
numbers. How can I customize this code to accomplish this?
 
It's largely a case of just deciding what options you want to give your
users, then building a form that allows them to pick out those choices, and
then (the hard part) translating those choices into a filter string.

An examples:
You want users to be able to print up to a specific ID number, or from an ID
number onwards, or between two different IDs.
There are various ways of laying that form out, but suppose you go for two
textboxes StartID and EndID. If only the start is completed then do that
one onwards, if just the end then up to that ID, and if both then do the
range.

That would then be:
if isnull(me.startid)
if isnull(me.endid)
msgbox "You must complete one or the other"
else
strsql="IDField<="&cstr(me.endid)&" and "
endif
else
strsql=strsql&"IDField>="&cstr(me.startid)&" and "
endif
strsql=left(strsql,len(strsql)-5)

Note that as each part is added, you ensure that the string always ends with
" and " (so that you can chop if off at the end without risking actually
losing something that you need.)

As a starting point, it's a good idea to build a query reflecting the
options you're going to be making available. You can then do a View, View
SQL to see the SQL of that. You'll be looking at recreating the conditions
after the WHERE clause.

And... start small and work up.
 

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

Back
Top