Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wish to export selected data from an access database to excel. Can I

Status
Not open for further replies.

neerajam

Technical User
Mar 4, 2002
23
0
0
US
I have a production database with all production related data. I would only like to export selected data from the entire database such as date, scrap, production, type of complaint to excel. I am not interested in sending the entire database. Right now, with the Docmd.Transferspreadsheet command, I can send the entire database and save it to a folder. Cna I do this and if so how. Any help would very much be appreciated. Thanks.
 
Hi!

Write a query with only the information that you need to export, you can also set criteria to limit the records you get. Then you can use the transferspreadsheet naming the query as what you want to export.

hth
Jeff Bridgham
bridgham@purdue.edu
 
neerajam, Create the query to find the data you want to send to excel. Try this fucntion, using your query info:

Function TransferYourQuery ()
On Error GoTo TransferYourQuery_Err

DoCmd.TransferSpreadsheet acExport, 8, "YourQuery", "C:\WhereverYourExcelFileIs\ContinueToInputYourFullPathToExcel", True, ""


mcrTransferYourQuery_Exit:
Exit Function

mcrTransferYourQuery_Err:
MsgBox Error$
Resume mcrTransferYourQuery_Exit

End Function

I just did this exact same thing yesterday. HOWEVER, I am NOT a vba pro. I first created this in a macro (using the TransferSpreadsheetAction), and followed 'Help' along figuring out the action arguments. I then coverted the macro to vba so I could figure out how to do it in code! Hope this helps you to figure it out. montrose Learn what you can and share what you know.
 
neerajam, jebry's was posting at the same time I was. Even though I previewed my post, of course it wasn't until it was up that I saw I did not remove the "mcr" from my converted code. So it would read instead:


Function TransferYourQuery ()
On Error GoTo TransferYourQuery_Err

DoCmd.TransferSpreadsheet acExport, 8, "YourQuery", "C:\WhereverYourExcelFileIs\ContinueToInputYourFullPathToExcel", True, ""


TransferYourQuery_Exit:
Exit Function

TransferYourQuery_Err:
MsgBox Error$
Resume TransferYourQuery_Exit

End Function

Again, HTH, montrose
Learn what you can and share what you know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top