By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,352 Members | 1,593 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,352 IT Pros & Developers. It's quick & easy.

Exporting excel file from Access, how to add additional columns?

100+
P: 167
I am using a query to select my columns from a table and then I am using the export function to export the results to an excel spreadsheet. I need to add to blank columns to the end, "Verified Year" and "Verified By". These columns are not on the table. I know I can manually add them to the excel spreadsheet but I am creating an automated process using vba code to create & export this so there will not be any manual intervention. Therefore, when the query is executed (select colA, colB, colC from table), I need to have this select statement somehow create these 2 additional columns.
Any suggestions?

Thanks!
Aug 24 '10 #1

✓ answered by NeoPa

Try using :
Expand|Select|Wrap|Line Numbers
  1. SELECT mytable.colA
  2.      , mytable.colB
  3.      , mytable.colC
  4.      , Null AS Add_Column1

Share this Question
Share on Google+
5 Replies


NeoPa
Expert Mod 15k+
P: 31,560
I would have thought creating empty columns in your query with the names to match the columns you want should work fine for you.
Aug 24 '10 #2

100+
P: 167
I have tried "select mytable.colA, mytable.colB, mytable.colC, "add_column1"
from mytable;

This give me the header 'Expr1007' and populates each row with the data value "add_column1". What I need is the column header to be "add_column1" and the data rows should be empty.

I have tried several different ways to do this and have not been succesful.

Thanks
Aug 24 '10 #3

NeoPa
Expert Mod 15k+
P: 31,560
Try using :
Expand|Select|Wrap|Line Numbers
  1. SELECT mytable.colA
  2.      , mytable.colB
  3.      , mytable.colC
  4.      , Null AS Add_Column1
Aug 24 '10 #4

100+
P: 167
That worked! Thanks. Some times I tend to over think the simple things! Thanks for your quick response!
Aug 24 '10 #5

NeoPa
Expert Mod 15k+
P: 31,560
No worries. These things are always so much easier when you've done them before many times.
Aug 24 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.