S
Santiago
I cannot make this query work...
first I make the sql string like this:
sSQLString = "SELECT * FROM [tblBASE] WHERE VESSEL LIKE 'MSC*' "
Then I use this string in the following code, connecting to an Access
database. I just want to retreive data of all records where vessel starts
with "MSC".
Public Sub retrieveData(sSQL As String)
Dim RECSET As ADODB.Recordset
Dim connectionString As String
Dim fila As Long
Dim sheet As Worksheet
Set sheet = ActiveSheet
connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & ActiveWorkbook.path & "\Tracking.mdb;"
fila = 5
Set RECSET = New ADODB.Recordset
Call RECSET.Open(sSQL, _
connectionString, , , _
CommandTypeEnum.adCmdText)
If Not RECSET.EOF Then
Call sheet.Range("a" & fila).CopyFromRecordset(RECSET)
Else
Call MsgBox("Error: No data found", vbCritical)
End If
With sheet.Range("5:5000")
.RowHeight = 15
End With
If (RECSET.State And ObjectStateEnum.adStateOpen) Then RECSET.Close
Set RECSET = Nothing
End Sub
Any idea that may help me???
thanks! bregards Santiago
first I make the sql string like this:
sSQLString = "SELECT * FROM [tblBASE] WHERE VESSEL LIKE 'MSC*' "
Then I use this string in the following code, connecting to an Access
database. I just want to retreive data of all records where vessel starts
with "MSC".
Public Sub retrieveData(sSQL As String)
Dim RECSET As ADODB.Recordset
Dim connectionString As String
Dim fila As Long
Dim sheet As Worksheet
Set sheet = ActiveSheet
connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & ActiveWorkbook.path & "\Tracking.mdb;"
fila = 5
Set RECSET = New ADODB.Recordset
Call RECSET.Open(sSQL, _
connectionString, , , _
CommandTypeEnum.adCmdText)
If Not RECSET.EOF Then
Call sheet.Range("a" & fila).CopyFromRecordset(RECSET)
Else
Call MsgBox("Error: No data found", vbCritical)
End If
With sheet.Range("5:5000")
.RowHeight = 15
End With
If (RECSET.State And ObjectStateEnum.adStateOpen) Then RECSET.Close
Set RECSET = Nothing
End Sub
Any idea that may help me???
thanks! bregards Santiago