Mentko Kolk said:
I am trying to handle Ms-Access fiednames with a variable name in VBA
programs. Name's field in MS-ACCESS Table: POOL(1), POOL(2), POOL(3),
POOL(4),
POOL(5), POOL(6) and in VBA: me!pool(id) and id is a variable integer
form 1 to 6.
Is thit possible? Can anyone help?
You have to build the control name as a string, and use that string as
the index into the Controls collection of the form (assuming this is a
form we're talking about).
Are your fields, and the controls bound to them, really named "POOL(1)"
and so on? That's really a bad idea, as it's going to cause you no end
of problems. However, if that's so, you can do what I think you're
asking like this:
Dim id As Integer
Dim strControlName As String
For id = 1 to 6
strControlName = "POOL(" & id & ")"
Debug.Print strControlName, Me.Controls(strControlName)
Next id
Further comment: Numbered, repeating field names like this generally
reflect a faulty table design. These fields should be stored as
separate records in a related table of Pools.