ACCESS (Query) to EXCEL

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

guys,
please help me..

im creating a report and i need to export data from my access database to
EXCEL.

how can i export it.. all i know is to import data from excel to access
using the wizard...

thanks..

amsuria
 
Hi Amsuria

I recommend trying to export a table or query, rather than a report. You can
either use a macro with the TransferSpreadsheet action, or VBA code. Here is
a VBA code example that exports a query named "qryMovieSelections" to the
same folder that the .mdb file is running from:


Private Sub cmdExportToExcel_Click()
On Error GoTo ProcError

Dim strPath As String
strPath = CurrentProject.Path

DoCmd.OutputTo acOutputQuery, "qryMovieSelections", acFormatXLS, _
strPath & "\MovieSelections.xls" ', AutoStart:=-1

MsgBox "The selected movies have been exported to the " _
& "file MovieSelections.xls" & vbCrLf & "in the folder:" _
& vbCrLf & strPath, vbInformation, "Export Complete..."

ExitProc:
Exit Sub

ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, , _
"Error in cmdExportToExcel_Click event procedure..."
Resume ExitProc
End Sub


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
GREAT!

I love this site.. all my inquiries were solved through this.. lol!

thanks again, Tom..

amsuria
 

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

Back
Top