Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADODB.Recordset truncation problem

Status
Not open for further replies.

merdealors

Programmer
Joined
Apr 22, 2007
Messages
2
Location
US
The following is causing a truncation when copying. Can't seem to get a handle on it. Can anyone help?



Public Function ProcDataMIN(ByRef xlwb As Workbook, ByRef xlws As Worksheet, _
ByRef currentrow As Long, filename As String, fpath As String, _
SearchValue1, override, xCount) As Long
Dim adoXL As ADODB.Connection
Dim adoRS As ADODB.Recordset
Dim filepath As String
Dim sqlstr As String
Dim rngstr As String
rngstr = "A" & currentrow
filepath = fpath & "\"
sqlstr = "Select * from [Sheet1$] Where [F1] > 40000 AND [F7] = " & SearchValue1
Set adoXL = New ADODB.Connection

With adoXL
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & filepath & filename & ";" & _
"Extended Properties=""Excel 8.0; HDR=No;"""
.Open
End With

Set adoRS = New ADODB.Recordset
adoRS.Open sqlstr, adoXL
xlws.Range(rngstr).CopyFromRecordset adoRS
xlws.Range("E" & currentrow & ":E" & currentrow + xCount - 1).Value = "M"
xlws.Range("F" & currentrow & ":F" & currentrow + xCount - 1).Value = override
currentrow = currentrow + xCount - 1
adoRS.Close

Set adoRS = Nothing
Set adoXL = Nothing
ProcDataMIN = currentrow
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top