Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This
code = Fields(1).value at least should be code = rs.Fields(1).value but where is the problem, which line of code? -- HTH Bob Phillips (remove nothere from email address if mailing direct) "ina" wrote in message ups.com... 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
yes thanks I understood the problem I commented the set rs ... and I
had a problem with that. a really thank you for you help. Ina |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
yes thanks I understood the problem I commented the set rs ... and I
had a problem with that. a really thank you for you help. Ina |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Runtime Error '91' Object variable or With block variable not set | Excel Discussion (Misc queries) | |||
Getting inconsistent Error 91-Object variable or With block variable not set | Excel Programming | |||
Run-time Error'91: Object variable or With block variable not set | Excel Programming | |||
Run-time error '91': "Object variable or With block variable not set | Excel Programming | |||
Cells.Find error Object variable or With block variable not set | Excel Programming |