gnod
09-24-2006, 08:55 AM
Hi,
why is it the rst.EOF = true?
In my query in access, i'm trying to get all RefCode which starts in "AAF"
but if i change "AAF*" into "AAFGenCar", the rst.EOF = False..
Const strMdbQryName As String = "qrySPL_REV_AA"
Sub SPL_ImportFromAccessToExcelByADO()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strMdbPath As String, strMdbFilename As String
Dim intRow As Integer, intCol As Integer
Dim Cell As Range
Dim blnFound As Boolean
strMdbFilename = "Co-Wide Consol - Revenue.mdb"
strMdbPath = ThisWorkbook.Path & "\" & strMdbFilename
Set cnn = New ADODB.Connection
Set rst = New ADODB.Recordset
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & strMdbPath & ";"
With rst
.Open strMdbQryName, cnn, adOpenForwardOnly, , adCmdTable
SPLLoop_REV:
Do Until rst.EOF
For Each Cell In Worksheets("SummaryPerLoc").Range("SPL_LocCode")
If rst.Fields("OriginCode") = Cell Then
intRow = Cell.Row
blnFound = True
End If
If blnFound = True Then
With Worksheets("SummaryPerLoc")
.Unprotect modConsolRevMisc.strPassword
.Cells(intRow, 3).Value = rst.Fields(1).Value
.Cells(intRow, 4).Value = rst.Fields(2).Value
.Cells(intRow, 5).Value = rst.Fields(3).Value
.Cells(intRow, 6).Value = rst.Fields(4).Value
blnFound = False
rst.MoveNext
.Protect modConsolRevMisc.strPassword
End With
GoTo SPLLoop_REV
End If
Next Cell
Loop
End With
rst.Close
Set rst = Nothing
cnn.Close
Set cnn = Nothing
End Sub
Can someone help me??
Thanks...
why is it the rst.EOF = true?
In my query in access, i'm trying to get all RefCode which starts in "AAF"
but if i change "AAF*" into "AAFGenCar", the rst.EOF = False..
Const strMdbQryName As String = "qrySPL_REV_AA"
Sub SPL_ImportFromAccessToExcelByADO()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strMdbPath As String, strMdbFilename As String
Dim intRow As Integer, intCol As Integer
Dim Cell As Range
Dim blnFound As Boolean
strMdbFilename = "Co-Wide Consol - Revenue.mdb"
strMdbPath = ThisWorkbook.Path & "\" & strMdbFilename
Set cnn = New ADODB.Connection
Set rst = New ADODB.Recordset
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & strMdbPath & ";"
With rst
.Open strMdbQryName, cnn, adOpenForwardOnly, , adCmdTable
SPLLoop_REV:
Do Until rst.EOF
For Each Cell In Worksheets("SummaryPerLoc").Range("SPL_LocCode")
If rst.Fields("OriginCode") = Cell Then
intRow = Cell.Row
blnFound = True
End If
If blnFound = True Then
With Worksheets("SummaryPerLoc")
.Unprotect modConsolRevMisc.strPassword
.Cells(intRow, 3).Value = rst.Fields(1).Value
.Cells(intRow, 4).Value = rst.Fields(2).Value
.Cells(intRow, 5).Value = rst.Fields(3).Value
.Cells(intRow, 6).Value = rst.Fields(4).Value
blnFound = False
rst.MoveNext
.Protect modConsolRevMisc.strPassword
End With
GoTo SPLLoop_REV
End If
Next Cell
Loop
End With
rst.Close
Set rst = Nothing
cnn.Close
Set cnn = Nothing
End Sub
Can someone help me??
Thanks...