p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   Beginning VB 6 (http://p2p.wrox.com/beginning-vb-6-75/)
-   -   Exporting data to Excel (http://p2p.wrox.com/beginning-vb-6/7358-exporting-data-excel.html)

lrickett December 17th, 2003 11:50 AM

Exporting data to Excel
 
I am trying to export data from Access to Excel and then subsequently send the data via Outlook to particular users. Using the following code, I was able to get the data to export once, but can't seem to get it to export again. I receive the following error:

Run-time error 3422: Can't modify table structure. Another user has the table open.

Code:
    Function ExporttoExcel()
    'Open Excel Workbook, export the data, then close the wkbk.

    Dim openWorkbook As Object, name As String
    Set openWorkbook = Workbooks.Open("D:\Recertifications.xls")

        DoCmd.TransferSpreadsheet acExport, _
                SpreadsheetType:=acSpreadsheetTypeExcel9, _
                TableName:="Recertifications", _
                FileName:="D:\Recertifications.xls", _
                HasFieldNames:=True

       openWorkbook.Close

    End Function

ANY help to get this working properly would be great!
THANKS.

lrickett December 23rd, 2003 09:45 AM

I fixed my own problem by doing the export a different way. I used an event procedure on a form called Month:

DoCmd.OutputTo acQuery, "qry_month", "MicrosoftExcel(*.xls)", "D:\Recertifications.xls"

However, now I need to filter this data to a particular month the user chooses in a control(Combo26 which lets the user choose a month) on a form (Month).

In qry_month which is getting exported, I created a field called RecertMonth which returns only the month of the expiration date. In the criteria for this field, I used:
[Forms]![Month]![Combo26]

I thought this was correct, but I get the following error:

The action or method is invalid because the form or report
isn't bound to a table or query.

I attempted to make the control bound, but that resulted in nothing being exported. Any suggestions on where I am going wrong?

s_satish October 29th, 2004 01:37 AM

Hi,
I want to exprt data from MS-Access to MS-Excel using Java programming.
Any one can help to do this.

Thanks.:)


Shally2h February 10th, 2011 01:27 AM

I want to introduce one article about how to export data from database to Excel, Word, PDF and so on. It mainly shows us how to use a small tool and provides an address for download the free component, you can read this article on http://www.codeproject.com/KB/cs/Exc...ExportWiz.aspx


All times are GMT -4. The time now is 07:01 PM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.