Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Importing / Linking / February 2007

Tip: Looking for answers? Try searching our database.

Exporting Access Data into Excel Programatically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Madhuri - 07 Jul 2005 17:14 GMT
hi all,

I want to export access data into excel in a MS Access form based on when
the user clicks the button some fields from a main form and subform should be
ported into excel sheet. Is this possible programatically ? If yes how do I
go about it ?

Thanks
Madhuri
Ken Snell [MVP] - 07 Jul 2005 20:21 GMT
Assuming that your report is using a query as its record source, you can use
DoCmd.TransferSpreadsheet to export that query to an EXCEL file. See
TransferSpreadsheet in Help file.

Signature

       Ken Snell
<MS ACCESS MVP>

> hi all,
>
[quoted text clipped - 7 lines]
> Thanks
> Madhuri
Madhuri - 07 Jul 2005 20:58 GMT
Hi Ken

I am trying to do thisin the MSaccess form coding

I added a button to run Excel application and the code for the button looks
like this

Private Sub Command93_Click()
On Error GoTo Err_Command93_Click
   DoCmd.TransferSpreadsheet(acExport, acSpreadsheetTypeExcel9,
qKPWC_RECOUP, "C:\TRY", YES)

Exit_Command93_Click:
   Exit Sub

Err_Command93_Click:
   MsgBox Err.Description
   Resume Exit_Command93_Click
   
End Sub

but the code dosent run and is giving me an error

1) It gives me a error that a = is included somewhere. Does the
transferdatasheet action return any value. If it does what datatype does it
return

I tried modifying and added a
Dim x as integer
and assigned
x =    DoCmd.TransferSpreadsheet(acExport, acSpreadsheetTypeExcel9,
qKPWC_RECOUP, "C:\TRY", YES)
thinking that it might be returning a numeric value
but now while executing the code it gives me
Compile error : highlighted on Transferspreadsheet method
"Expected function or variable"

Please help

Madhuri

> Assuming that your report is using a query as its record source, you can use
> DoCmd.TransferSpreadsheet to export that query to an EXCEL file. See
[quoted text clipped - 11 lines]
> > Thanks
> > Madhuri
Ken Snell [MVP] - 07 Jul 2005 21:54 GMT
Don't put ( ) around the arguments. Also, specify the full path to the EXCEL
file, including the filename. And, use True not Yes.

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, qKPWC_RECOUP,
"C:\TRY\FileNameIs.xls", True

Signature

       Ken Snell
<MS ACCESS MVP>

> Hi Ken
>
[quoted text clipped - 58 lines]
>> > Thanks
>> > Madhuri
Madhuri - 07 Jul 2005 22:04 GMT
Thanks Ken, that worked

Please also tell me how to open the excel sheet after its created without
closing msaccess.

Thanks in advance
Madhuri

> Don't put ( ) around the arguments. Also, specify the full path to the EXCEL
> file, including the filename. And, use True not Yes.
[quoted text clipped - 64 lines]
> >> > Thanks
> >> > Madhuri
Madhuri - 07 Jul 2005 22:33 GMT
Thank you,

I solved it. I used shell command to open the excel sheet.

Thanks for all the support Ken.

Madhuri

> Thanks Ken, that worked
>
[quoted text clipped - 72 lines]
> > >> > Thanks
> > >> > Madhuri
Ken Snell [MVP] - 08 Jul 2005 02:10 GMT
You're welcome.

Signature

       Ken Snell
<MS ACCESS MVP>

> Thank you,
>
[quoted text clipped - 87 lines]
>> > >> > Thanks
>> > >> > Madhuri
Lee - 27 Feb 2007 20:50 GMT
I am trying to do a similar thing but I have the error msg - The MS Jet
Database Engine could not find the object (table name).

What is qKPWC_RECOUP?

Thanks for your help!

> You're welcome.
>
[quoted text clipped - 89 lines]
> >> > >> > Thanks
> >> > >> > Madhuri
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.