peispud
asked on
Use For Next loop to refer to data fields
Hi
Using Microsoft Access (latest version)
By example database fields
[Item 1] --- Text field
[Item 2] --- Text field
[Item 3] --- Text field
etc ... They are identical except by their numerical component in the name.
I would like to be able to do the following.
Using Microsoft Access (latest version)
By example database fields
[Item 1] --- Text field
[Item 2] --- Text field
[Item 3] --- Text field
etc ... They are identical except by their numerical component in the name.
I would like to be able to do the following.
dim xxx as long
for xxx = 1 to 3
"[Item" & xxx & "]".visible = true
next xxx
Any help would be appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
it would be possible:
dim xxx as long for xxx = 1 to 3
controls("Item" & xxx ).visible = true
next xxx
dim xxx as long for xxx = 1 to 3
controls("Item" & xxx ).visible = true
next xxx
ASKER
Thank you
To add on a bit to Guy's comment, you can also do that with fields in a record set:
rst("myFieldsName" & xxx) = <some value>
So you'd get myFieldName1, myFieldName2, myFieldName3, etc
This type of syntax is what Access converts to internally when working with objects. so it's a tad faster as well in that it doesn't have to do the conversion.
Jim.
rst("myFieldsName" & xxx) = <some value>
So you'd get myFieldName1, myFieldName2, myFieldName3, etc
This type of syntax is what Access converts to internally when working with objects. so it's a tad faster as well in that it doesn't have to do the conversion.
Jim.
ASKER