Assigning fields to variables

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

Guest

Hi,

I need to do a lot of calculations on fields within a form but I need to
perform the calculations without 'hard coding' the field names, eg

for i = 1 to 20
sField = "Field" & cstr(i)
.............
next i

The problem I have is updating the field specified in variable sField.

I have tried using

For Each Control In Me.Controls
if control.name = sField then
...........
end if
next control

but this seems very inefficient, is there a better way to do this?

Many thanks for any help.
 

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

Back
Top