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: 26
Default ADO & SQL

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
 
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



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