ACCESS (Query) to EXCEL

A

amsuria

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
 
T

Tom Wickerath

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
__________________________________________
 
A

amsuria

GREAT!

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

thanks again, Tom..

amsuria
 
Top