Re: string is interperted literally



pmacdiddie@xxxxxxxxx wrote:

On Jan 4, 12:07 am, CDMAPos...@xxxxxxxxxxxxxxxx wrote:

On Jan 3, 11:29 pm, pmacdid...@xxxxxxxxx wrote:






Sorry, I know this has been done 1000 times. The problem is i need to
loop though a recordset and I dont know the field names, so they have
to be looked up. When i pass them to get the values, it passes as a
literal.

fcount = rs.Fields.Count
'Debug.Print fcount
For i = 0 To fcount - 1

StrText = StrText & "rs![" & rs.Fields(i).Name & "] & "
Debug.Print StrText

ctGrid0.AddColumn rs.Fields(i).Name, rs.Fields(i).Size
ctGrid0.ColumnSortable(i) = -1

If fcount - i = 1 Then
Do While Not rs.EOF

ncount = ctGrid0.AddItem(StrText) ****** Problem is here,
StrText is interperted as string

rs.MoveNext
Loop
rs.Close
End If

Thanks in advance for the help.

Maybe:

varFieldValue = rs(rs.Fields(i).Name)

Note: varFieldValue can be Null.

James A. Fortune
CDMAPos...@xxxxxxxxxxxxxxxxx Hide quoted text -

- Show quoted text -


unfortunately that does not work either. I am able to get the value
initially, so I can get the value inside the for loop, but in the do
while loop, the variables are treated as text, so i get the same thing
all the way through the record set.

Wouldn't your value of strText be something like
"rs![Field1] & rs![Field2] & rs![Field3] & rs![Field4] & "...
when you get to 1?

You put a
Debug.Print StrText
in your code. Whats the output? Something like
rs![Field1] &
rs![Field1] & rs![Field2] &
rs![Field1] & rs![Field2] & rs![Field3] &
rs![Field1] & rs![Field2] & rs![Field3] & rs![Field4] &
?

You mention "StrText is interperted as string". Most of us would think that strText is a string. What do you think it should be?

Flowers
http://www.youtube.com/watch?v=hMGpGZvr-G0
.



Relevant Pages

  • Re: Strange behaviour with 2 recordsets
    ... Do you think that that is the cause of the outer loop to quit after 2 ... I use only 1 recordset, ... after the correction on the double "strstr" in "Dim ... strstrWhere As String" and give you a feedback. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Keep getting an Subscript Out of Range....
    ... sLabel As String ... Dim CircPts() As POINTAPI ... The recordset has a RecordCount property that is known ... before entering the loop. ...
    (microsoft.public.vb.general.discussion)
  • Re: Email list
    ... Dim strEmail As String ... 'Open ADO recordset change YourEmailTable to the name of the table or query ... 'Clear strEmail Variable ... 'Start to loop through the recordset ...
    (microsoft.public.access.macros)
  • Loop through query
    ... I have the loop part figured out. ... Dim rst As ADODB.Recordset ... Dim stDocName As String ...
    (microsoft.public.access.queries)
  • Loop through query
    ... Yes I need another recordset. ... >I have the loop part figured out. ... >Dim rst As ADODB.Recordset ... > Dim stDocName As String ...
    (microsoft.public.access.queries)