问题
I have a table in MS-Access that needs to contain an array of 4 (type number) values. At the moment they are in named fields, VAL1, VAL2, VAL3, VAL4. However, that’s cumbersome (the number of values may be larger) because I want to use a loop in the associated VBA code, which generates a binary data file from the database tables.
Is it possible for VBA to access table fields using raw index values? As an example, if I have a table with the following fields:
Name VAL1 VAL2 VAL3 VAL4
Can I reference fields using generic names and indices, so that my 4 VAL fields can be accessed in a loop using a structure such as TableName.field(i)?
回答1:
I think it will be a lot better for you now, and especially in the long run, if you name your fields relevant to what they actually represent. That's my .02.
来源:https://stackoverflow.com/questions/43348622/how-to-handle-arrays-in-access-tables