variable inside a DAO recordset field qualifier?

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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
 
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
 
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
 
Back
Top