variable inside a DAO recordset field qualifier?

G

Guest

I'm using DAO and Jet on Access 2003.

I have a recordset defined as:

Dim rst As DAO.Recordset

I would like to use the recordset to update a record. I know that the syntax
is..

rst![columnName] = value

What I want to do is be able to assign a value to any different column names
that could exist in the rst recordset. So I can updated different columns of
the recordset depending on different conditions. I tried to do this...

rst![rstA![columnName] ] = value <-- this does not work

Is it possible to place a variable fieldname inside the brackets?
 
R

RoyVidar

david101 said:
I'm using DAO and Jet on Access 2003.

I have a recordset defined as:

Dim rst As DAO.Recordset

I would like to use the recordset to update a record. I know that the
syntax is..

rst![columnName] = value

What I want to do is be able to assign a value to any different
column names that could exist in the rst recordset. So I can
updated different columns of the recordset depending on different
conditions. I tried to do this...

rst![rstA![columnName] ] = value <-- this does not work

Is it possible to place a variable fieldname inside the brackets?

Try

rst.fields(rstA![columnName]) = value
 
M

Marshall Barton

david101 said:
I'm using DAO and Jet on Access 2003.

I have a recordset defined as:

Dim rst As DAO.Recordset

I would like to use the recordset to update a record. I know that the syntax
is..

rst![columnName] = value

What I want to do is be able to assign a value to any different column names
that could exist in the rst recordset. So I can updated different columns of
the recordset depending on different conditions. I tried to do this...

rst![rstA![columnName] ] = value <-- this does not work

Is it possible to place a variable fieldname inside the brackets?


Use parenthesis:

rst(strcolumnName) = value

or, more formally:

rst.Fields(strcolumnName) = value
 
G

Guest

Thank you Roy and Marshall that is exactly what is needed

Marshall Barton said:
david101 said:
I'm using DAO and Jet on Access 2003.

I have a recordset defined as:

Dim rst As DAO.Recordset

I would like to use the recordset to update a record. I know that the syntax
is..

rst![columnName] = value

What I want to do is be able to assign a value to any different column names
that could exist in the rst recordset. So I can updated different columns of
the recordset depending on different conditions. I tried to do this...

rst![rstA![columnName] ] = value <-- this does not work

Is it possible to place a variable fieldname inside the brackets?


Use parenthesis:

rst(strcolumnName) = value

or, more formally:

rst.Fields(strcolumnName) = value
 

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