LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Getting records from Access 97 to Excel 97

Hi everyone,

In my code below, I am accessing a Access 97 database to
grab some records and place these in my Excel 97
spradsheet. When the code is ran, I am getting back
heading names in my SQL statement, but no data. I have
checked the SQL statemnt in Access and I get data
returned, but not while in Excel. This one has me stumpted.

Here's the code from Excel VBE:

Sub PlantProductLines()
Dim DBFullName As String
Dim Cnct As String, Src As String
Dim Connection As ADODB.Connection
Dim Recordset As ADODB.Recordset
Dim Col As Integer
Dim Row As Integer

Dim strPlantName As String

'Database Information
DBFullName = "J:\QA\QAMaster\QAMaster.mdb"

'Open the connection
Set Connection = New ADODB.Connection
Cnct = "Provider=Microsoft.Jet.OLEDB.4.0; "
Cnct = Cnct & "Data Source=" & DBFullName & ";"
Connection.Open ConnectionString:=Cnct

'Create RecordSet
strPlantName = ActiveSheet.Range("L4").Value
Set Recordset = New ADODB.Recordset

With Recordset
'Filter
Src = "SELECT qryPlantProductLine.PlantName,
qryPlantProductLine.LineCode, qryPlantProductLine.LineName
FROM `J:\QA\QAMaster\QAMaster`.qryPlantProductLine
qryPlantProductLine WHERE
(qryPlantProductLine.PlantName='Leola')"
.Open Source:=Src, ActiveConnection:=Connection
Debug.Print .MaxRecords
Debug.Print .RecordCount

'Write the field names
For Col = 0 To Recordset.Fields.Count - 1
Range("P12").Offset(0, Col).Value =
Recordset.Fields(Col).Name
Next
MsgBox Recordset.RecordCount
End With

Set Recordset = Nothing
Connection.Close
Set Connection = Nothing
End Sub
 
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
Import Access records into Excel dksaluki Excel Discussion (Misc queries) 1 December 20th 07 07:08 AM
Linking Access Records to Excel MayraEllen Excel Worksheet Functions 0 August 21st 06 07:37 PM
How to Get records from a query in access and put them in Excel Andy Wiggins Excel Programming 0 December 21st 03 10:51 AM
How to Get records from a query in access and put them in Excel pikus Excel Programming 0 December 21st 03 02:27 AM
Access records updating from Excel. Dirk Batenburg Excel Programming 2 October 8th 03 03:06 PM


All times are GMT +1. The time now is 12:28 PM.

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

About Us

"It's about Microsoft Excel"