Exporting to Excel from Access

D

Daniel

Within the database, I have an option to export the main table to an excel
spreadsheet.

Is it possible to code into Access what fields to export, should the user
want to do this.

Lets say the table has FieldA, FieldB and FieldC - if they only wanted to
export FieldA, and ignore FieldB and FieldC, is this possible - assuming
this is possible, how easy would it be to create some sort of form, which
pops up when a command button is clicked asking which fields you want
exported, or a checkbox(?) saying !all fields"

Hope that all makes sense

Thanks in advance

Daniel
 
D

Daniel

Hi Doug

Seems my brain wasn't working correctly this morning! Query has now been
created, but.... is there anyway, within the form, that the user can pick
and choose which fields they want to export - what I want to do is edit the
query within the form, so the user doesn't actually see the query itself -
in an ideal world, check boxes would be available for each field within the
query, that can be checked, then the command button clicked to export those
fields selected

I've had a browse on the net, but can't find what I'm looking for....

Thanks in advance

Daniel
 
D

Douglas J. Steele

You can build the SQL of the query dynamically.

Your form needs to present all of the fields in the table and allow the
users to select which ones they want. Once you know the fields of interest,
you generate the SQL and then change the SQL of the query along the lines
of:

Dim qdf As DAO.QueryDef
Dim strSQL As String

strSQL = ....
Set qdf = CurrentDb.QueryDefs("MyQuery")
qdf.SQL = strSQL
Set qdf = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top