Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fields object 2

Status
Not open for further replies.

cabobound

Programmer
Jul 11, 2007
80
US
Hi all,

I am trying to access a field through the field object. I have a list of fields that runs from 01-54, 01r-54r. The code I have I can access the 01-54 but not the 01r-54r. Is there something wrong with the code or is it impossible to access this way?

<%cntr
While cntr<55%>
...
<%=fi.fields(cntr & "r")%>
...
<%cntr=cntr+1
Wend%>

I have also tried to by access by name with the variable cntr:
<%=fi(cntr & "r")%>

This never works. Is it possible to access fields this way?

Thanks...
KT
 
<%cntr
While cntr<55%>
...
<%=fi.fields([!]Right("00" & cStr([/!]cntr[!]), 2)[/!] & "r")%>
...
<%cntr=cntr+1
Wend%>

You are treating cntr as a number, but it appears as though your column names are zero padded, so something like this may work. It's worth a try. [smile]

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
ok something weird is happening. it will loop through the code and I can access the field name and the values, after the loop it gives me an error: "Item cannot be found in the collection corresponding to the requested name or ordinal." on the same line that just printed the field name and the value for each

<%While x.eof=False
response.write Right("00" & cStr(cntr), 2) & " " & fi.fields(Right("00" & cStr(cntr), 2)) & "<br>" (<-error msg)

If fi.fields(Right("00" & cStr(cntr), 2))=x("Item") and fi.fields(Right("00" & cStr(cntr), 2))=true Then%>
...

output...
01 True
02 False
03 False
....


I can understand if it cant find the field but to allow me to print the value for it then claim it cant find it?
 
"Item cannot be found in the collection corresponding to the requested name or ordinal.

That is because you have tried to go PAST the fi.EOF


While x.eof=False

how does x correspond to fi? because if x.eof and fi.eof are NOT the same it may try (is going to) to read BEYOND fi.eof

AND You would be better using a Do ... Until ... Loop rather than the while ... wend loop



Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
The first code worked at accessing the fields. I did need to modify the code as I looped through, the x RST is a recordset that reads through data. Anyways, here's what worked:

<%cntr=1
sTr="Select * From [Inspection Items] Order By [Item]"
set x=xConn.Execute(sTr)

While cntr<55
If fi.fields(Right("00" & cStr(cntr), 2))=true Then%>

Thanks for the help!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top