string is interperted literally

string is interperted literally

am 04.01.2008 05:29:29 von pmacdiddie

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.

Re: string is interperted literally

am 04.01.2008 06:07:29 von CDMAPoster

On Jan 3, 11:29=A0pm, pmacdid...@gmail.com wrote:
> Sorry, I know this has been done 1000 times. =A0The problem is i need to
> loop though a recordset and I dont know the field names, so they have
> to be looked up. =A0When i pass them to get the values, it passes as a
> literal.
>
> =A0 fcount =3D rs.Fields.Count
> =A0 =A0 =A0 =A0 'Debug.Print fcount
> =A0 =A0For i =3D 0 To fcount - 1
>
> =A0 =A0 =A0 StrText =3D StrText & "rs![" & rs.Fields(i).Name & "] & "
> =A0 =A0 =A0 Debug.Print StrText
>
> =A0 =A0 =A0 ctGrid0.AddColumn rs.Fields(i).Name, rs.Fields(i).Size
> =A0 =A0 =A0 ctGrid0.ColumnSortable(i) =3D -1
>
> =A0 =A0 =A0 If fcount - i =3D 1 Then
> =A0 =A0 =A0 =A0 =A0 =A0 Do While Not rs.EOF
>
> =A0 =A0 =A0 =A0 =A0 =A0 ncount =3D ctGrid0.AddItem(StrText) =A0****** Prob=
lem is here,
> StrText is interperted as string
>
> =A0 =A0 =A0 =A0 =A0 =A0 rs.MoveNext
> =A0 =A0 =A0 =A0 =A0 =A0 Loop
> =A0 =A0 =A0 =A0 =A0 =A0 rs.Close
> =A0 =A0 =A0 =A0 End If
>
> Thanks in advance for the help.

Maybe:

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

Note: varFieldValue can be Null.

James A. Fortune
CDMAPoster@FortuneJames.com

Re: string is interperted literally

am 04.01.2008 12:43:53 von pmacdiddie

On Jan 4, 12:07=A0am, CDMAPos...@fortunejames.com wrote:
> On Jan 3, 11:29=A0pm, pmacdid...@gmail.com wrote:
>
>
>
>
>
> > Sorry, I know this has been done 1000 times. =A0The problem is i need to=

> > loop though a recordset and I dont know the field names, so they have
> > to be looked up. =A0When i pass them to get the values, it passes as a
> > literal.
>
> > =A0 fcount =3D rs.Fields.Count
> > =A0 =A0 =A0 =A0 'Debug.Print fcount
> > =A0 =A0For i =3D 0 To fcount - 1
>
> > =A0 =A0 =A0 StrText =3D StrText & "rs![" & rs.Fields(i).Name & "] & "
> > =A0 =A0 =A0 Debug.Print StrText
>
> > =A0 =A0 =A0 ctGrid0.AddColumn rs.Fields(i).Name, rs.Fields(i).Size
> > =A0 =A0 =A0 ctGrid0.ColumnSortable(i) =3D -1
>
> > =A0 =A0 =A0 If fcount - i =3D 1 Then
> > =A0 =A0 =A0 =A0 =A0 =A0 Do While Not rs.EOF
>
> > =A0 =A0 =A0 =A0 =A0 =A0 ncount =3D ctGrid0.AddItem(StrText) =A0****** Pr=
oblem is here,
> > StrText is interperted as string
>
> > =A0 =A0 =A0 =A0 =A0 =A0 rs.MoveNext
> > =A0 =A0 =A0 =A0 =A0 =A0 Loop
> > =A0 =A0 =A0 =A0 =A0 =A0 rs.Close
> > =A0 =A0 =A0 =A0 End If
>
> > Thanks in advance for the help.
>
> Maybe:
>
> varFieldValue =3D rs(rs.Fields(i).Name)
>
> Note: varFieldValue can be Null.
>
> James A. Fortune
> CDMAPos...@FortuneJames.com- 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.

Re: string is interperted literally

am 04.01.2008 13:26:09 von Lyle Fairfield

pmacdiddie@gmail.com wrote in news:a36e8558-ba97-4468-8825-77cb3a335bb8
@r60g2000hsc.googlegroups.com:

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

It has snowed here a lot recently. I have been clearing my driveway with a
screw-driver. There have been problems. So I wrote into Comp-
Driveways/OldMan-Clear and asked for help with [clearing my driveway with a
screw-driver]. Some kind soul there suggested that almost never does one
NEED to clear his/her driveway with a screw-driver and that possibly I
should ask for suggestion on how to [clear my driveway].
When I did that, someone suggested that I use a shovel. Now I can’t
remember what the problem with the screw-driver was.
PS My driveway is clear.

Re: string is interperted literally

am 04.01.2008 17:56:31 von Salad

pmacdiddie@gmail.com wrote:

> On Jan 4, 12:07 am, CDMAPos...@fortunejames.com wrote:
>
>>On Jan 3, 11:29 pm, pmacdid...@gmail.com 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...@FortuneJames.com- 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

Re: string is interperted literally

am 04.01.2008 18:57:49 von Tony Toews

pmacdiddie@gmail.com 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.

Why don't you know the field names?

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/