Refer to recordset field by string

J

John J.

If I have the following code,
rs!MyTestField = "Testval"
How can I refer to MyTestField as a string?
I tried things like rs!(strTest) and rs![(strTest)] but I can't get it to
work.

Thanks,
John
 
R

RoyVidar

John said:
If I have the following code,
rs!MyTestField = "Testval"
How can I refer to MyTestField as a string?
I tried things like rs!(strTest) and rs![(strTest)] but I can't get
it to work.

Thanks,
John

Almost there, try

rs(strTest)

Or, what I would use, which is a bit more explicit

rs.fields(strTest).value
 
S

sweet_dreams

Hi John,

try this:
rs.fields("field_name")
or
rs.fields(field_index_number)

Regards,
Sebastian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top