Using Variables to Reference a Field Name

G

Guest

Hello,

I'm trying to use a de-referenced variable to access a field name. For
example, if I have several fields named sequentially F1, F2, F3, F4, etc...
and I want to programmatically construct the field name to reference these
fields with a variable for the numeric part of the field name in a recordset,
how would I accomplish this?

Looking for something like:

NewVar = Recset!F

Where "Recset" is a recordset to the table, and i is a loop variable that
counts from 1 to some higher value. I seem to remember that there is some
way to construct field names dynamically like this. Any help would be
appreciated.

Thanks, -BOBJ
 
T

Tim Ferguson

I'm trying to use a de-referenced variable to access a field name.
For example, if I have several fields named sequentially F1, F2, F3,
F4, etc...

.... then you have a big Design Problem...
and I want to programmatically construct the field name to
reference these fields with a variable for the numeric part of the
field name in a recordset, how would I accomplish this?

Looking for something like:

NewVar = Recset!F


NewVar = Recset.Fields("F" & format(i,"0"))


.... but seriously, I would look at either reconstructing this thing into
a database or using a spreadsheet app.

Best wishes


Tim F
 
V

Vincent Johns

Tim said:
... then you have a big Design Problem...

I agree, it looks that way. What do these fields mean?

[...]
... but seriously, I would look at either reconstructing this thing into
a database or using a spreadsheet app.

Best wishes

Tim F

Or both. You might consider using Excel spreadsheets to do your
calculations (are you inverting matrices, or something, that requires
array structures?), and linking to part of the Excel file as an Access
(linked) Table that makes the results of the calculations available to
your Queries, Reports, &c.

-- Vincent Johns <[email protected]>
Please feel free to quote anything I say here.
 

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