Sevn
I trust ME!
- Local time
- Today, 16:31
- Joined
- Mar 13, 2008
- Messages
- 97
Hello All,
I am working on an export module, that I can't seem to figure out.
My project:'
I have a form that has 2 combo boxes, and one "Go" button.
I have a parameter query that is based on the combo box inputs.
I have a XLS template with 8 worksheets. The 8 worksheets are named based on the 8 different categories within field "VolCat" (1A, 1B, 1C, 1D, 2A, 2B, 2C, 2D)
When the "Go" button is pressed, I would like my query to be exported (not viewed) to Excel. I would like the records to export to their appropriate worksheet based on the value found in the "VolCat" field. So; if someone selects "ALL" from the combo box, all of the records will be directly exported to Excel to the correct worksheet. If someone selects VolCat "2A", then only the 2A worksheet will be populated upon run-time.
I currently have a separate query for each category, that are exported one at a time into a single workbook...RUNS VERY SLOW. Also; I will need this same type of setup for a few different reports, so I will end up making 8 queries for each report. This is not good, since I have 6+ reports. I don't think 48 queries is the best way of doing this.
If someone could send me some sample code, or lead me in the right direction, it would be greatly appreciated.
I'm assuming that there is a way that I can query/export in one VBA command.
Such as:
DoCmd.OutputTo acOutputQuery,"ExportQry-CPMByCompany", acFormatXLS, "file loc" WHERE "VolCat" = "1A" (To Worksheet 1A)
DoCmd.OutputTo acOutputQuery,"ExportQry-CPMByCompany", acFormatXLS, "file loc" WHERE "VolCat" = "1B" (To Worksheet 1B)
ETC...
This would allow me to have 1 query, but achieve the same results I need.
Thanks,
Sevn
I am working on an export module, that I can't seem to figure out.
My project:'
I have a form that has 2 combo boxes, and one "Go" button.
Company, VolCat
Within the VolCat combo box, I have eight unique items, and an "ALL" item. The ALL items references a "*", so I may grab all records.
I have a parameter query that is based on the combo box inputs.
I have a XLS template with 8 worksheets. The 8 worksheets are named based on the 8 different categories within field "VolCat" (1A, 1B, 1C, 1D, 2A, 2B, 2C, 2D)
When the "Go" button is pressed, I would like my query to be exported (not viewed) to Excel. I would like the records to export to their appropriate worksheet based on the value found in the "VolCat" field. So; if someone selects "ALL" from the combo box, all of the records will be directly exported to Excel to the correct worksheet. If someone selects VolCat "2A", then only the 2A worksheet will be populated upon run-time.
This is where I am having issues.
I currently have a separate query for each category, that are exported one at a time into a single workbook...RUNS VERY SLOW. Also; I will need this same type of setup for a few different reports, so I will end up making 8 queries for each report. This is not good, since I have 6+ reports. I don't think 48 queries is the best way of doing this.
If someone could send me some sample code, or lead me in the right direction, it would be greatly appreciated.
I'm assuming that there is a way that I can query/export in one VBA command.
Such as:
DoCmd.OutputTo acOutputQuery,"ExportQry-CPMByCompany", acFormatXLS, "file loc" WHERE "VolCat" = "1A" (To Worksheet 1A)
DoCmd.OutputTo acOutputQuery,"ExportQry-CPMByCompany", acFormatXLS, "file loc" WHERE "VolCat" = "1B" (To Worksheet 1B)
ETC...
This would allow me to have 1 query, but achieve the same results I need.
Thanks,
Sevn