using variable to ref. recordset field

J

John Thomas

I am having trouble using a variable in a Recordset, I have, RS as Recordset

Then when I try to use it in the following statement, I want to use a
variable in stead of the field name, but it says it cannot find the field. I
have verified the variable is right, so it must be in the syntax?

Dim var4 as String 'is the variable field name

I've tried the following variations with it but none work:

var1 = RS!var4

var1 = RS![var4]

var1 = RS![" & var4 & "]

Thanks John
 
J

John Thomas

Thanks, worked great!

Ken Snell said:
Close....

var1 = RS.Fields(var4)


--
Ken Snell
<MS ACCESS MVP>

John Thomas said:
I am having trouble using a variable in a Recordset, I have, RS as Recordset

Then when I try to use it in the following statement, I want to use a
variable in stead of the field name, but it says it cannot find the
field.
I
have verified the variable is right, so it must be in the syntax?

Dim var4 as String 'is the variable field name

I've tried the following variations with it but none work:

var1 = RS!var4

var1 = RS![var4]

var1 = RS![" & var4 & "]

Thanks John
 

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