Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 4th, 2010, 05:23 PM
Registered User
Join Date: Nov 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Runtime 424 object required - unconverted database

Hello, I'm hoping someone can help. We just upgraded to Access 2007 and I have a database that is still in native 2003 that I'm getting a "runtime 424 object required" error message on a particular report that exports into excel. I'm not sure what is different in 2007 vs. 2003 but this code is not working in 2007. If I click through all of the 'end' messages, the excel spreadsheet does eventually come up with the correct data.

Below is the code, which I didn't not create so I'm flying a little blind:

Public Function fExportReportInfoToExcel(strFilterDate As Variant, strFilterPlant As Variant, _
strFilterDepartment As Variant, strFilterLine As Variant, strFilterMaterial As Variant, _
strFilterShift As Variant, strFilterTargetWtRange As Variant, strFilterTechnician As Variant, _
strReportHeader As Variant, strYAxis As Variant, RsSql As Variant, _
strFilterFinishBatchNo As String, strFilterWtCtrlFrmNo As String) '091604 KLK new Finished Batch Number upgrade. Added strFilterFinishBatchNo , strFilterWtCtrlFrmNo
Dim DB As DAO.Database, Rs As DAO.Recordset
Dim i As Integer, J As Integer
'RsSql = recordset query string
Dim CurrentValue As Variant
Dim CurrentField As Variant
Dim Workbook As Object
Dim xlApp As Object
Dim Sheet As Object
Set DB = DBEngine.Workspaces(0).Databases(0)

Set Rs = DB.OpenRecordset(RsSql, dbOpenDynaset)
Set xlApp = CreateObject("Excel.Application")
Set Sheet = xlApp.Workbooks.Open(strExcelSpreadsheet, , True).Sheets("data")

J = 1

Sheet.Cells(11, 6).Value = 2 '

' Loop through the Microsoft Access field names and create
' the Microsoft Excel labels.
For i = 0 To Rs.Fields.Count - 1
CurrentValue = Rs.Fields(i).Name
Sheet.Cells(J, i + 1).Value = CurrentValue
Next i

J = 2

' Loop through the Microsoft Access records and copy the records
' to the Microsoft Excel spreadsheet.
Do Until Rs.EOF
For i = 0 To Rs.Fields.Count - 1
CurrentField = Rs(i)
Sheet.Cells(J, i + 1).Value = CurrentField
Next i
J = J + 1

' Put the value of the ToExcel text box into the cell on the
' spreadsheet and make the cell bold.
strFilterDate = "'" & strFilterDate
Sheet.Cells(1, 6).Value = strFilterDate
Sheet.Cells(2, 6).Value = strFilterPlant
Sheet.Cells(3, 6).Value = strFilterDepartment
Sheet.Cells(4, 6).Value = strFilterLine
Sheet.Cells(5, 6).Value = strFilterMaterial
Sheet.Cells(6, 6).Value = strFilterShift
Sheet.Cells(7, 6).Value = strFilterTargetWtRange
Sheet.Cells(8, 6).Value = strFilterTechnician
Sheet.Cells(9, 6).Value = strReportHeader
Sheet.Cells(10, 6).Value = strYAxis
Sheet.Cells(11, 6).Value = J - 1 '
'091604 KLK new start Finished Batch Number upgrade.
Sheet.Cells(12, 6).Value = strFilterFinishBatchNo
Sheet.Cells(13, 6).Value = strFilterWtCtrlFrmNo '
'091604 KLK new end Finished Batch Number upgrade.

xlApp.Worksheets("Print Out").Range("A1").Activate

' Print the Microsoft Excel spreadsheet.
Sheet.Application.Visible = True

' cleanup.
Set Sheet = Nothing
Set xlApp = Nothing

End Function'

Thanks in advance.

The runtime error is coming in at the code that is red above.


Last edited by panda2; November 5th, 2010 at 03:34 PM..

Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Time Error 424 "Object Required" paul31berks Access VBA 8 October 31st, 2010 04:49 PM
runtime error 424: object required anjana BOOK: Excel 2003 VBA Programmer's Reference 0 July 13th, 2009 12:44 PM
VBA Object required - RTE 424 dbrother Access VBA 2 November 2nd, 2007 04:06 PM
VBScript runtime (0x800A01A8) Object required SeanW Classic ASP Databases 8 February 21st, 2007 01:03 AM
Runtime Error 424: Object needed tobian Excel VBA 4 February 20th, 2006 10:41 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.