PDA

View Full Version : referring to fields with variables


NancyJ
10-12-2005, 03:41 PM
When I do this:
rs.fields(0).name its fine.
editfield = 0
when I do rs.fields(editfield).name I get
Item cannot be found in the collection corresponding to the requested name or ordinal.

neocool00
10-12-2005, 04:49 PM
My first guess would be because "editfield" is delcared as a variant instead of an integer, even though you have assigned it a numeric value.

NancyJ
10-12-2005, 05:49 PM
eval(editfield) works :)

Bullschmidt
10-13-2005, 05:34 AM
Thanks for sharing what worked!

And if anyone is reading this and is curious a little more about Eval():

Using the Eval and Execute Functions - 3/3/2000
http://www.4guysfromrolla.com/webtech/030300-1.shtml

NancyJ
10-13-2005, 09:14 AM
I'm guessing cint would have also worked. The number came from the querystring so its automatically a string. so it was looking for rs("0") rather than rs(0). I should have known really, its not like its not something I dont encounter every day comparing recordset integers to form or querystring id numbers :s