Specify Field with Variable Data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to write a DO Loop and have value assigned to a field. The field
to which the value is assigned would vary based on the number if times
through the loop, based on a counter, for exmaple.

Dim Level string
Dim Counter integer

If I have looped three times, the counter will be equal to three. I want to
concatenate the word Level and 3, and assign a value to that field, hence
LEVEL3 = 5

I have
Level = "level" + trim(str(counter))
"...Then [Level] = Left..."

But I can't seem to get it to assign it to the field. The 'Level' value
will not direct the value to the field.

Any ideas?
 
You don't specify a field in what. Assuming it's a recordset, you'd use
rs.Fields(Level).
 
It is a field in a form. I will try this and see if it works.

Susan

Douglas J. Steele said:
You don't specify a field in what. Assuming it's a recordset, you'd use
rs.Fields(Level).

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Blonde CE said:
I am trying to write a DO Loop and have value assigned to a field. The
field
to which the value is assigned would vary based on the number if times
through the loop, based on a counter, for exmaple.

Dim Level string
Dim Counter integer

If I have looped three times, the counter will be equal to three. I want
to
concatenate the word Level and 3, and assign a value to that field, hence
LEVEL3 = 5

I have
Level = "level" + trim(str(counter))
"...Then [Level] = Left..."

But I can't seem to get it to assign it to the field. The 'Level' value
will not direct the value to the field.

Any ideas?
 
In a form, it would be Me.Controls(Level)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Blonde CE said:
It is a field in a form. I will try this and see if it works.

Susan

Douglas J. Steele said:
You don't specify a field in what. Assuming it's a recordset, you'd use
rs.Fields(Level).

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Blonde CE said:
I am trying to write a DO Loop and have value assigned to a field. The
field
to which the value is assigned would vary based on the number if times
through the loop, based on a counter, for exmaple.

Dim Level string
Dim Counter integer

If I have looped three times, the counter will be equal to three. I
want
to
concatenate the word Level and 3, and assign a value to that field,
hence
LEVEL3 = 5

I have
Level = "level" + trim(str(counter))
"...Then [Level] = Left..."

But I can't seem to get it to assign it to the field. The 'Level'
value
will not direct the value to the field.

Any ideas?
 
Back
Top