How to export data to Excel from a sub-form for a particular recor

G

Guest

MS Access 2000, Windows XP
======================
Hi,

I have a form for person information (names) and a subform for the Cars
owned by that person. I'd like to export the data/records visible in the Car
subform to an Excel spreadsheet. I've added a button to export the data using
the following code:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qselCar",
"c:\Documents and Settings\avirmani\Desktop\DataTransfer.xls", True

qselCar is the record source for the subform.

But, this is exporting ALL the records in the query qselCar. I'd like to
export the records only for that specific person.

Is there a way to limit the records that are visible in the subform for that
particular person? I didn't see a place for a "where" clause or to specify a
condition.
 
G

Guest

create a similar query to "qselCar", name it "qselCar_Export", on the
criteria of the new query link to your form's person, then in the line where
you are export the query replace the name of the query with "qselCar_Export".

The criteria in your new query will look like:

[Forms]![MyForm]![PersonId]
 
G

Guest

jl5000 said:
create a similar query to "qselCar", name it "qselCar_Export", on the
criteria of the new query link to your form's person, then in the line where
you are export the query replace the name of the query with "qselCar_Export".

The criteria in your new query will look like:

[Forms]![MyForm]![PersonId]

Thanks for your response. That worked!!

-Amit
 

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