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

Access Tables to Excel Worksheet Export

P: n/a
Hello, I've recently been asked to work with Microsoft Access, and
while I feel quite comfortable with Excel, I'm at a complete loss with
databases. If someone could help me with this issue I'm having I'd be
most appreciative. The database is already constructed, I'm just
wanting to export the data to an excel file.

In short, I'm hoping to export two Tables (or queries...not sure which
to use - they both seem to have the same data) in a Microsoft Access
database to a single blank worksheet (already created, lets call it:
'Data') in Microsoft Excel one right after another (order is
irrelevant). Let's call one of the Access tables: TCC, and the other
TCP.

The TCC and TCP tables have 5 and 6 columns respectively (although I
only wish the first 4 columns to be sent to the excel file), and have
similar titles (not exactly the same in all cases) but the contents of
each column is consistent with the ones on the other ( i.e. Column 4
on both are formatted as dates, column 3 contains numbers, column 2
contains text, and column 1 contains a name, but when I try to export
it to excel (not sure if I'm doing it right - I'm really clueless when
it comes to Access), I get an ID number. I would like if possible to
retain the name, as shown when viewing in the query, but this isn't a
life-or-death issue.

Now here is where it gets tricky:
I only wish for the entries whose dates (in the 4th column) are
between or include two dates on a different worksheet (called 'Entry
Form', located in the same excel file to be listed/pasted on the
'Data' worksheet. More specifically, cell C9 contains the beginning
date and C10 is the ending date. If/When one of these dates are
changed, I need the list of data exported from the two tables to be
updated. Also, I can't have any changes made to the excel file to
modify the data in the Access file. I'm not sure what other info you
may need, the dates in the 4th column for both TCC and TCP have a
field name of "Week Ending"

Thank you so much,
Stefan

Mar 16 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Mar 15, 7:15 pm, smacz...@gmail.com wrote:
Hello, I've recently been asked to work with Microsoft Access, and
while I feel quite comfortable with Excel, I'm at a complete loss with
databases. If someone could help me with this issue I'm having I'd be
most appreciative. The database is already constructed, I'm just
wanting to export the data to an excel file.

In short, I'm hoping to export two Tables (or queries...not sure which
to use - they both seem to have the same data) in a Microsoft Access
database to a single blank worksheet (already created, lets call it:
'Data') in Microsoft Excel one right after another (order is
irrelevant). Let's call one of the Access tables: TCC, and the other
TCP.

The TCC and TCP tables have 5 and 6 columns respectively (although I
only wish the first 4 columns to be sent to the excel file), and have
similar titles (not exactly the same in all cases) but the contents of
each column is consistent with the ones on the other ( i.e. Column 4
on both are formatted as dates, column 3 contains numbers, column 2
contains text, and column 1 contains a name, but when I try to export
it to excel (not sure if I'm doing it right - I'm really clueless when
it comes to Access), I get an ID number. I would like if possible to
retain the name, as shown when viewing in the query, but this isn't a
life-or-death issue.

Now here is where it gets tricky:
I only wish for the entries whose dates (in the 4th column) are
between or include two dates on a different worksheet (called 'Entry
Form', located in the same excel file to be listed/pasted on the
'Data' worksheet. More specifically, cell C9 contains the beginning
date and C10 is the ending date. If/When one of these dates are
changed, I need the list of data exported from the two tables to be
updated. Also, I can't have any changes made to the excel file to
modify the data in the Access file. I'm not sure what other info you
may need, the dates in the 4th column for both TCC and TCP have a
field name of "Week Ending"

Thank you so much,
Stefan

1) you can use DoCmd.TransferSpreadsheet (http://www.mvps.org/access/
general/gen0008.htm) to export data from your Access database to an
Excel spreadsheet; you can create a query that will return only the
first four columns of a table, and use this as the 'source' of this
export.
2) in order to have both tables output to the same worksheet, you will
need to create a UNION query (http://www.devguru.com/technologies/
jetsql/QuickRef/union.html) that will combine the data from each table
(or, more specifically, the subset of the data that your queries will
return): Example query: SELECT field1, field2, field3, field4 FROM
TCC UNION SELECT field1, field2, field3, field4 FROM TCP;.
A more visual example of a union query can be found at
http://en.wikipedia.org/wiki/Union_(SQL)
3) in order to know the date constraints that need to be applied,
you'll need to use Automation to access the Excel spreadsheet
containing those constraints (http://www.mvps.org/access/modules/
mdl0006.htm); you'll need to open that spreadsheet, read the values,
and apply them to your query using either a "parameter query" or by
using VBA to construct a SQL query manually and then execute it using
DAO or ADO.
4) as for executing this process "when one of those dates are
changed", that's not exactly possible; you'll need your database to
periodically check that spreadsheet to see if it has changed, unless
of course you want to add code to your Excel spreadsheet that's
executed when those cells are changed, and calls a macro in your
database initiating the export process.

Would it be simpler to just use DoCmd.transferspreadsheet to dump the
data, and manually manipulate it? How automated does this process
need to be?
Mar 16 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.