Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default troubles not bringing in the first row of a ado query to another spreadsheet...


...troubles not bringing in the first row of a ado query...

this code works well, BUT I have found that this code doesn’t copy i
the first row of the recordset

???


Code:


Do Until filenameI = ""

strSourceFile = PATH & filenameI

mytab = Mid(filenameI, 1, InStr(1, filenameI, ".") - 1)

strsql = "SELECT * FROM [" & mytab & "$];"

'connection...

Set cn = New ADODB.Connection

'open connection...

cn.Open "DRIVER={Microsoft Excel Drive
(*.xls)};DriverId=790;ReadOnly=True;" & _

"DBQ=" & strSourceFile & ";"

'recordset

Set rs = New ADODB.Recordset

'open rs

rs.Open strsql, cn, adOpenForwardOnly, adLockReadOnly, adCmdText

'copy in rs

Selection.End(xlDown).Select

ActiveCell.Offset(1, 0).Select

ActiveCell.CopyFromRecordset rs

‘clean-up

rs.Delete

rs.Close

filenameI = Dir()

Loop

thank you..

--
mjschuka
-----------------------------------------------------------------------
mjschukas's Profile: http://www.excelforum.com/member.php...nfo&userid=969
View this thread: http://www.excelforum.com/showthread.php?threadid=39458

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default troubles not bringing in the first row of a ado query to another s

I have never tried a CopyFromRecordSet with adOpenForwardOnly; perhaps that
is the issue (Open command reads first record; so the CopyFromRecordset can
only move forward from there??? Just speculating). Try adOpenDynamic and
see if that helps.
--
- K Dales


"mjschukas" wrote:


...troubles not bringing in the first row of a ado query...

this code works well, BUT I have found that this code doesnt copy in
the first row of the recordset

???


Code:


Do Until filenameI = ""

strSourceFile = PATH & filenameI

mytab = Mid(filenameI, 1, InStr(1, filenameI, ".") - 1)

strsql = "SELECT * FROM [" & mytab & "$];"

'connection...

Set cn = New ADODB.Connection

'open connection...

cn.Open "DRIVER={Microsoft Excel Driver
(*.xls)};DriverId=790;ReadOnly=True;" & _

"DBQ=" & strSourceFile & ";"

'recordset

Set rs = New ADODB.Recordset

'open rs

rs.Open strsql, cn, adOpenForwardOnly, adLockReadOnly, adCmdText

'copy in rs

Selection.End(xlDown).Select

ActiveCell.Offset(1, 0).Select

ActiveCell.CopyFromRecordset rs

€˜clean-up

rs.Delete

rs.Close

filenameI = Dir()

Loop

thank you...


--
mjschukas
------------------------------------------------------------------------
mjschukas's Profile: http://www.excelforum.com/member.php...fo&userid=9695
View this thread: http://www.excelforum.com/showthread...hreadid=394584


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default troubles not bringing in the first row of a ado query to another spreadsheet...


thank you...!

i will try...

thanks!


K Dales Wrote:
I have never tried a CopyFromRecordSet with adOpenForwardOnly; perhaps
that
is the issue (Open command reads first record; so the CopyFromRecordset
can
only move forward from there??? Just speculating). Try adOpenDynamic
and
see if that helps.
--
- K Dales


"mjschukas" wrote:


...troubles not bringing in the first row of a ado query...

this code works well, BUT I have found that this code doesnt copy

in
the first row of the recordset

???


Code:


Do Until filenameI = ""

strSourceFile = PATH & filenameI

mytab = Mid(filenameI, 1, InStr(1, filenameI, ".") - 1)

strsql = "SELECT * FROM [" & mytab & "$];"

'connection...

Set cn = New ADODB.Connection

'open connection...

cn.Open "DRIVER={Microsoft Excel Driver
(*.xls)};DriverId=790;ReadOnly=True;" & _

"DBQ=" & strSourceFile & ";"

'recordset

Set rs = New ADODB.Recordset

'open rs

rs.Open strsql, cn, adOpenForwardOnly, adLockReadOnly, adCmdText

'copy in rs

Selection.End(xlDown).Select

ActiveCell.Offset(1, 0).Select

ActiveCell.CopyFromRecordset rs

€˜clean-up

rs.Delete

rs.Close

filenameI = Dir()

Loop

thank you...


--
mjschukas

------------------------------------------------------------------------
mjschukas's Profile:

http://www.excelforum.com/member.php...fo&userid=9695
View this thread:

http://www.excelforum.com/showthread...hreadid=394584




--
mjschukas
------------------------------------------------------------------------
mjschukas's Profile: http://www.excelforum.com/member.php...fo&userid=9695
View this thread: http://www.excelforum.com/showthread...hreadid=394584

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
Import New Database Query (Union Query) in Spreadsheet klock Excel Discussion (Misc queries) 2 September 24th 09 01:30 AM
bringing in colours from another spreadsheet swifts Excel Discussion (Misc queries) 2 September 22nd 09 06:46 PM
Bringing in a Union Query with excel? S Davis Excel Worksheet Functions 3 August 24th 06 06:52 PM
Spreadsheet query Michael Dedman Excel Programming 1 June 30th 04 04:52 PM
Bringing info from userform to spreadsheet David Excel Programming 3 December 8th 03 03:09 AM


All times are GMT +1. The time now is 10:10 AM.

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"