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: 5
Default getting data from access

Hey all, I am trying to get data from access and inserting it in excel. I
have multiple table and multiple queries. I did get one query to work but now
on my second I seem to have a problem that i can find.

Sub ProcessRecords()

Dim i As Integer
i = 1

'declares connection and record set
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

'initialize connect and recordset
Set cn = New Connection
Set rs = New Recordset

cn.Provider = "Microsoft.jet.oledb.4.0"
cn.ConnectionString = "Data Source = S:\12 Students NOPP8\CO31Emile Boudreau
(Jan2006-Apr 2006)\Indmon 2005.mdb"

cn.Open
rs.Open "select * from [Production]", cn

Sheets("Sheet2").Select
Range("A1").Select

Do While rs.EOF < True
ActiveCell.Value = rs.Fields("MILL_ID").Value ' from = to
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.Value = rs.Fields("P_TOTALE").Value
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.Value = rs.Fields("P_DATE").Value

i = i + 1
Range("A" & i).Select

rs.MoveNext
Loop

rs.Close

Sheets("Sheet2").Name = "Production"

cn.Close

Set rs = Nothing
Set cn = Nothing
End Sub

Now i know that i have information because in access i see it and the query
gets data in access but when i try to run in in VB "rs" has no records in it.
(rs.EOF = true) This makes no sense as i know it should pick data up.

Does anyone have an idea of what is going wrong here?

thanks in advance for the help.
 
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
Removing Data Tables formed from importing data from Access Andrea Jones Excel Discussion (Misc queries) 0 April 10th 08 12:01 PM
Can Excel access data from Access?! Al Excel Discussion (Misc queries) 5 April 5th 08 03:52 PM
Calculate data from Access and return to Access Mary Fran Excel Programming 0 January 17th 06 02:10 PM
Transfer Data from Excel 2000 to the Access data base André Lavoie Excel Programming 1 September 28th 05 03:22 PM
Access data -work in Excel- save in Access s_u_resh Excel Programming 1 October 25th 04 12:52 PM


All times are GMT +1. The time now is 08:29 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"