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 March 2nd, 2006, 02:59 PM
Authorized User
 
Join Date: Mar 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Automation error..maybe missing parameter?

I posted this in the Excel forum as well but since it relates to Access thought you might also have a look. TIA

Could you all look for a problem in this ADO? TIA

Public Sub PlainTextQuery()

    Dim rsData As ADODB.Recordset
    Dim szConnect As String
    Dim szSQL As String

    szConnect = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
                "Data Source=C:\Test\Calls.mdb; "

    szSQL = "SELECT Date, Skillset, Calls " & _
            "FROM Calls " & _
            "ORDER BY Date"

    Set rsData = New ADODB.Recordset
    rsData.Open szSQL, szConnect, adOpenForwardOnly, adLockReadOnly, adCmdText

    If Not rsData.EOF Then
        Sheet1.Range("A2").CopyFromRecordset rsData
        rsData.Close
        With Sheet1.Range("A1:C1")
            .Value = Array("Date", "Skillset", "Calls")
            .Font.Bold = True
        End With
        Sheet1.UsedRange.EntireColumn.AutoFit
    Else
        MsgBox "Error: No Records Returned.", vbCritical
    End If

    If CBool(rsData.State And adStateOpen) Then rsData.Close
    Set rsData = Nothing

End Sub

Gives Run-time error '-2147217904(80040e10)

This is almost identical to one in the VBA books. Thanks.


 
Old March 2nd, 2006, 11:09 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Hi kalebson,

On the face of it, there is nothing wrong with the code you have. It ran fine in my VBA project (Access XP SP3). I just added the Automation objects:

Code:
Dim xlApp As Object
Dim xlWb As Object
Dim Sheet1 As Object

Set xlApp = CreateObject("Excel.Application")
Set xlWb = xlApp.Workbooks.Add
Set Sheet1 = xlWb.Worksheets("Sheet1")

xlApp.Visible = True
Which line is your code breaking on? Are you using Office 2K3? Seems to be some problems using ADO with Excel 2K3 as I was discussing with nebbish last night at this link.

http://p2p.wrox.com/topic.asp?TOPIC_ID=40811

Might want to have a peak at the registry settings we were talking about. At any rate, your code worked for me.

HTH,

Bob

 
Old March 3rd, 2006, 09:37 AM
Authorized User
 
Join Date: Mar 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thats EXACTLY what it was Bob....per you post on 2k3..Thank you very much.

 
Old March 3rd, 2006, 11:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

That's interesting kalebson. The problem apparently throws a variety of erros (at least three) and is becoming fairly well documented, so I checked for any KB articles/hot fixes/service packs. You might want to have a look at:

http://support.microsoft.com/kb/904953/

This version of the problem becomes a known issue after the installation of Office 2003 Service Pack 2.

Bob

 
Old March 3rd, 2006, 11:48 AM
Authorized User
 
Join Date: Mar 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks again...I forwarded this info tou TS team...Ill let them do the updates here. Only 1 issue left on my other script and I think im good for the weekend. 5 PCs all the same HW/SW and I get an error and they dont on the same script....FUN one. Thanks again for your help.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Automation Error nagarajan123 Access 0 April 30th, 2008 09:22 AM
Missing Parameter Field Current Value vk18 Crystal Reports 2 December 26th, 2007 10:01 AM
Missing parameter in Jet OLEDB connection OldCoder ASP.NET 1.0 and 1.1 Professional 2 April 21st, 2006 11:29 PM
Automation error..maybe missing parameter? kalebson Excel VBA 1 March 3rd, 2006 09:38 AM
error 7866 when using automation pilmart Access 0 August 29th, 2003 02:57 PM





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