T
TheJim01
I'm using VBA & ADODB to maneuver through a recordset that contains a single
record.
All variables are defined per Option explicit, and are all properly initiated.
When I run the SQL statement in SQL view of an Access Query, I get a single
record with 7 fields. Each field contains the correct (non-null) value.
When I run the below code, I get message boxes that contain "*field name* = "
-- the value is null.
===== Code =====
Dim rs as ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open sqlstr, conn, adOpenDynamic, adLockReadOnly
If Not rs.EOF Then
rs.MoveFirst
For i = 0 To 6
MsgBox rs.Fields(i).Name & " = " & rs.Fields(i).Value
Next i
rs.close
End If
===== End Code =====
Oh, and the kicker is: this code worked yesterday.
So what gives? My connection must be OK, otherwise the query would be
bombing at the .Open command. I'm obviously receiving results, because it's
delivering message boxes. But where did my values fall out? Like I said,
I'm receiving results when I run the SQL outside VBA...
record.
All variables are defined per Option explicit, and are all properly initiated.
When I run the SQL statement in SQL view of an Access Query, I get a single
record with 7 fields. Each field contains the correct (non-null) value.
When I run the below code, I get message boxes that contain "*field name* = "
-- the value is null.
===== Code =====
Dim rs as ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open sqlstr, conn, adOpenDynamic, adLockReadOnly
If Not rs.EOF Then
rs.MoveFirst
For i = 0 To 6
MsgBox rs.Fields(i).Name & " = " & rs.Fields(i).Value
Next i
rs.close
End If
===== End Code =====
Oh, and the kicker is: this code worked yesterday.
So what gives? My connection must be OK, otherwise the query would be
bombing at the .Open command. I'm obviously receiving results, because it's
delivering message boxes. But where did my values fall out? Like I said,
I'm receiving results when I run the SQL outside VBA...