-
Jun 12th, 2018, 04:21 AM
#1
Thread Starter
Addicted Member
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?
-
Jun 12th, 2018, 04:40 AM
#2
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?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jun 12th, 2018, 06:25 AM
#3
Thread Starter
Addicted Member
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
Last edited by kutlesh; Jun 12th, 2018 at 07:24 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|