I am drawing a blank on the appropriate programming technique I need and would appreciate the wisdom of the group.
I have a database with approximately 300,000 accounting entries covering multiple years. I have created a form with a text list that displays several fields from the database. I want the user to be able to search the database with options for multiple criteria and so I have created five popup lists that populate choosing listchoices( from the five different main fields in the database. I have also set up two text editor boxes for entering a start and end date range.
I am not concerned about dynamic searching. I have a button “Run Query” that triggers a procedure that searches the database and redisplays the text list based on the results.
Here is my problem - how do I write the query procedure so that it ignores the fields where a user has not made a choice from one of the lists? It is unlikely that a user would want to filter on all five but might choose one or two or even three. As well, the user may or may not choose to restrict their search to a specific date range.
The only thing I can come up with is:
If fgDoneeChoice (the variable from the text list where the choice is stored) ≠““
select Donee = fgDoneeChoice endif
If fgPayeeChoice ≠““ selectwithin Payee = fgPayeeChoice endif
If fgFundChoice ≠““ selectwithin Fund = fgFundChoice endif
If fgTypeChoice ≠““ selectwithin TransType = fgTypeChoice endif
If fgAccountChoice ≠““ selectwithin Account = fgAccountChoice endif
if fgStartDate ≠”” and fgEndDate ≠”” selectwithin Date => date(fgStartDate) and Date <= date(fgEndDate) endif
This works, but obviously involves potentially six separate searches and while the speed is ok, it would be faster if somehow this could be combined into one search. Also the text list object flashes for each successive search.
Any ideas?
Thanks