LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
ina ina is offline
external usenet poster
 
Posts: 120
Default object variable or with variable not set

Hello :),

I am newbie in vba and this is my connection code but I have a problem
with rs.field I do not have the result of my query.

What can I do?


Sub connection()


Dim rs As ADODB.Recordset
Dim cnx As ADODB.Connection
Dim code As String

Set cnx = New ADODB.Connection


cnx.ConnectionString = {connection}

cnx.Open
'test de connection
If cnx.State = adStateOpen Then
End If

'Set cmd = New ADODB.Command
'Set cmd.ActiveConnection = cnx
'cmd.CommandText = "select * from clients"
'cmd.CommandType = adcomdtext

'Set rs = New ADODB.Recordset
'Set rs.Source = cmd

rs.ActiveConnection = cnx
rs.Open "select * from qrypacfund"

internalcode = rs.Fields(1).Value


Do While Not rs.EOF

code = Fields(1).value


rs.movenext

Loop

rs.Close
cnx.Close

Set cnx = Nothing
Set rs = Nothing

End Sub
Ina

 
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
Runtime Error '91' Object variable or With block variable not set Alec Coliver Excel Discussion (Misc queries) 2 October 24th 09 02:29 PM
Getting inconsistent Error 91-Object variable or With block variable not set mfq Excel Programming 0 December 14th 05 06:08 PM
Run-time Error'91: Object variable or With block variable not set DynamiteSkippy Excel Programming 4 September 26th 05 07:47 AM
Run-time error '91': "Object variable or With block variable not set Mike[_92_] Excel Programming 2 December 30th 04 10:59 AM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM


All times are GMT +1. The time now is 07:14 PM.

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"