Resolve component name at runtime in VBA/Access 2000?
i am building a helper application that runs custom queries. The problem is, there are like 60 "select" queries and each of them takes time to execute. So now I have put several check boxes which will filter which queries to execute and skip unwanted ones.
I can name my check boxes with some text and numbers, but since I am noob VBA programmer I am not sure how to make a check box name at runtime and reference the appropriate one.
If I do it manually I will need to add 60 lines of this
Code:
chkbox1.Value = True
chkBox2.Value = False
.
.
.
chkBox60.Value = False
How can I reference my check boxes at run-time with code?
Re: Resolve component name at runtime in VBA/Access 2000?
Code:
for i = 1 to 60
if controls("chkbox" & i).value = true then ' do stuff
next
is that something like you want?
Re: Resolve component name at runtime in VBA/Access 2000?
Yes this code snippet does the job perfectly:
Code:
Dim i as Integer
Dim checks(10) as Boolean
' add values to the array
for i = 0 to 9
Me.Controls("chkbox" & i).value = checks(i)
next i