filtering a report via a pop-up

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
Back
Top