I need a suggestion for the correct way to do something, so I can begin some research in that direction.
I have a search form that users can use to narrow down the contents of my database to a subset of records. They can view a quick listing of the results there, or open a more detailed view of a single record. I want to allow them to export the search results out to an excel file. When doing the export I want to allow the user to customize the output to only the information they need about each record. So currently, when a user has narrowed down his search, pressing the export button brings up a smaller window with a list of Headers and check boxes for each one. User will check the boxes he wants to, which will add those headers to the export, then clicks Finish and it generates the file. Seems simple enough in my head.
The search form that the user is accessing is running off a query to bring all my table data together. (Based on this.) However, that query (QRY_SearchAll) does not include everything that a user could select for export. So I duplicated that query: qryExport will use all the same search options, but also show me everything possible to export. I figure whatever I use to do the export can run off that query perhaps.
So the real questions is what direction do I go next? After the user has selected his/her headers, do I use those checks and a bunch of if statements to build a new SQL string and re-query only what I need exported? Use the already created query (qryExport) and add the records to the excel file one by one with a loop of some sort, omitting un-checked sections? Perhaps use or generate a query to create a temporary table so I can use a simple DoCmd.TransferSpreadsheet?
Also to take into consideration, I need to do some data manipulation as I perform the export. I have a field that has data that I want to separate as I export it. Inside Access as the user is using the DB he/she will never need it seperated, so I figure doing it at the time if export would be ok, especially if I am adding to excel record by record with a loop setup. (Example: a field has "4.5-1/8-10N 5056 AL Honeycomb Core" listed in Access, when doing the export I want to split out the beginning of that into 3 different columns using Split(). If needed I could separate these out inside access, and just never display them to the user.)
Any suggestions of a direction to take that would be considered the right way to do things? Or am I so far down the rabbit hole going the wrong direction that I have no real "right way" left?
Thanks!