Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Class doesn't support Automation...

Hi,

I am trying to connect to an access 2000 db using Excel 97
and query a table in the database and paste the recordset
into a worksheet. Here is the code I have so far...

Code:
Sub checkup()
Dim Cn As Object, Rs As Object, Status As String
Dim mySql As String, dbFullname As String, myCnt As Long
dbFullname = "l:\Cpe\Shape\Interim\Interim.mdb"
Status = Sheets("ridc checkup").Range("G7").Value  'SQL 
Variable
mySql = "SELECT ordernumber, mobilenumber " & _
    "FROM bookings WHERE " & _
    "status =" & Status & ";" 'Stack your SQL string
Status = Empty 'Clear SQL variable string

Set Cn = CreateObject("ADODB.Connection")
Cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" _
       & dbFullname & ";"  'Create DB connection
    
Set Rs = CreateObject("ADODB.Recordset")

With Rs
    Set .ActiveConnection = Cn
   .Source = mySql 'Pass your SQL
   .Open , , 3, 3
    myCnt = .RecordCount
   If myCnt  0 Then
        .MoveLast: .MoveFirst
         'Pull data to first sheet, cells 
a1:RecordestCountRow & column 3 _
            3 fields in the sql pass
        Sheets(2).Range(Cells(1, 2), Cells(myCnt, 
3)).CopyFromRecordset Rs
    End If
    Set myRng = Nothing
    .Close
End With
Cn.Close
Set Rs = Nothing: Set Cn = Nothing
End Sub
However, an error occurs at the line below saying that the
Class doesn't support automation:

Sheets(2).Range(Cells(1, 2), Cells(myCnt,
3)).CopyFromRecordset Rs

Any ideas on how to either fix or get around this
problem???
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Class doesn't support Automation...

Nathan,

I think CopyFromRecordest was not in XL97, introduced in XL2000.

--

HTH

Bob Phillips

"Nathan Stevens" wrote in message
...
Hi,

I am trying to connect to an access 2000 db using Excel 97
and query a table in the database and paste the recordset
into a worksheet. Here is the code I have so far...

Code:
 Sub checkup()
 Dim Cn As Object, Rs As Object, Status As String
 Dim mySql As String, dbFullname As String, myCnt As Long
 dbFullname = "l:\Cpe\Shape\Interim\Interim.mdb"
 Status = Sheets("ridc checkup").Range("G7").Value  'SQL
 Variable
 mySql = "SELECT ordernumber, mobilenumber " & _
     "FROM bookings WHERE " & _
     "status =" & Status & ";" 'Stack your SQL string
 Status = Empty 'Clear SQL variable string

 Set Cn = CreateObject("ADODB.Connection")
 Cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" _
        & dbFullname & ";"  'Create DB connection

 Set Rs = CreateObject("ADODB.Recordset")

 With Rs
     Set .ActiveConnection = Cn
    .Source = mySql 'Pass your SQL
    .Open , , 3, 3
     myCnt = .RecordCount
    If myCnt  0 Then
         .MoveLast: .MoveFirst
          'Pull data to first sheet, cells
 a1:RecordestCountRow & column 3 _
             3 fields in the sql pass
         Sheets(2).Range(Cells(1, 2), Cells(myCnt,
 3)).CopyFromRecordset Rs
     End If
     Set myRng = Nothing
     .Close
 End With
 Cn.Close
 Set Rs = Nothing: Set Cn = Nothing
 End Sub

However, an error occurs at the line below saying that the
Class doesn't support automation:

Sheets(2).Range(Cells(1, 2), Cells(myCnt,
3)).CopyFromRecordset Rs

Any ideas on how to either fix or get around this
problem???



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
getting support MOHAMMAD New Users to Excel 6 February 9th 09 03:53 PM
getting support MOHAMMAD New Users to Excel 1 February 9th 09 07:38 AM
I need some support [email protected] Excel Discussion (Misc queries) 1 January 16th 08 11:04 PM
XML support Alain B Excel Discussion (Misc queries) 1 May 15th 06 03:27 PM
XLL support discontinued? Edwin Knoppert Excel Programming 2 July 21st 03 05:22 PM


All times are GMT +1. The time now is 07:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"