I replaced all the SQL from the source code and replaced it with SQL = "SELECT * QueryExportData"
To address this:
The part that gets data is:
'SQL statement to retrieve data from database
SQL = "SELECT PartNo, PartName, Price, SalePrice, " & _
"(Price - SalePrice) / Price AS Discount " & _
"FROM Parts " & _
"ORDER BY PartNo "
So you can replace that SQL with your own. In other words, your fields in the SELECT clause and your table or query instead of Parts. At the very simplest:
SQL = "SELECT * FROM YourTableOrQuery"
which would return all fields and all records.
When I ran it I received an error " Error Number: 3075=Syntax error (missing operator) in query expression '* QueryExportData'. "
Thoughts??? I'm sure it's me...
Need FROM keyword.
SELECT * FROM QueryExportData
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
A trick I've often used is to record a macro in Excel (which is actually VBA) doing whatever I'm looking to automate. That gives you the shell of the code you need in Access. You always need to add the Excel object to the beginning, but like I said it gives you the guts of the code.
Now Macros I have can do... So you're saying record the formatting in access as a macro then take the code that was written to do that and copy it over to the VBA editor in Access? What additional code is needed to get access to read the formatting code after my "SELECT * FROM QueryExportData" statement?A trick I've often used is to record a macro in Excel (which is actually VBA) doing whatever I'm looking to automate. That gives you the shell of the code you need in Access. You always need to add the Excel object to the beginning, but like I said it gives you the guts of the code.
No, I'm saying record a macro in Excel then adapt the code for use in Access. If I didn't know how to bold and underline a cell, I'd record a macro doing that and then examine the code that Excel created.