473,378 Members | 1,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

complex loop

I have nine checkboxes in my form

named like this
check1
check2
check3
check4
...
check9

i want to create a loop that loops them and if they are checked then do something



i wrote something like this

Expand|Select|Wrap|Line Numbers
  1.  
  2. dim name as string
  3. dim iter as integer
  4. iter = 1
  5.  
  6.  
  7.  
  8. Do
  9.  
  10. name = "check" & iter
  11.  
  12. if me.name.value = -1 then
  13.  
  14.  do something
  15.  
  16. end if
  17.  
  18. iter = iter + 1
  19.  
  20. loop until iter = 10
  21.  
but i keep getting errors

i also tried something like this

Expand|Select|Wrap|Line Numbers
  1.  
  2. if check & iter.value = -1 then
  3.  
  4. do something
  5. end if
  6.  
  7.  
also error


how can i do the above loop??
Oct 22 '09 #1

✓ answered by ADezii

This code should work nicely, substitute your own Control Names within the Select Case construct:
Expand|Select|Wrap|Line Numbers
  1. Dim ctl As Control
  2.  
  3. For Each ctl In Me.Controls         'Analyze each Control on the Form
  4.   If ctl.ControlType = acCheckBox Then      'Is it a Check Box?
  5.     If ctl.Value Then       'Is it Checked?
  6.       Select Case ctl.Name      'Make a decision based on the Check Box selected
  7.         Case "Check1"
  8.           'process here for Check1
  9.         Case "Check2"
  10.           'process here for Check2
  11.         Case "Check3"
  12.           'process here for Check3
  13.         Case "Check4"
  14.           'process here for Check4
  15.         Case "Check5"
  16.           'process here for Check5
  17.         Case "Check6"
  18.           'process here for Check6
  19.         Case "Check7"
  20.           'process here for Check7
  21.         Case "Check8"
  22.           'process here for Check8
  23.         Case "Check9"
  24.           'process here for Check9
  25.       End Select
  26.     End If
  27.   End If
  28. Next

4 2094
ADezii
8,834 Expert 8TB
This code should work nicely, substitute your own Control Names within the Select Case construct:
Expand|Select|Wrap|Line Numbers
  1. Dim ctl As Control
  2.  
  3. For Each ctl In Me.Controls         'Analyze each Control on the Form
  4.   If ctl.ControlType = acCheckBox Then      'Is it a Check Box?
  5.     If ctl.Value Then       'Is it Checked?
  6.       Select Case ctl.Name      'Make a decision based on the Check Box selected
  7.         Case "Check1"
  8.           'process here for Check1
  9.         Case "Check2"
  10.           'process here for Check2
  11.         Case "Check3"
  12.           'process here for Check3
  13.         Case "Check4"
  14.           'process here for Check4
  15.         Case "Check5"
  16.           'process here for Check5
  17.         Case "Check6"
  18.           'process here for Check6
  19.         Case "Check7"
  20.           'process here for Check7
  21.         Case "Check8"
  22.           'process here for Check8
  23.         Case "Check9"
  24.           'process here for Check9
  25.       End Select
  26.     End If
  27.   End If
  28. Next
Oct 22 '09 #2
NeoPa
32,556 Expert Mod 16PB
Try the following :
Expand|Select|Wrap|Line Numbers
  1. Dim intX As Integer
  2.  
  3. For intX = 1 To 9
  4.     If Me.Controls("Check" & intX) Then
  5.         'Do something
  6.     End If
  7. Next intX
Unfortunately, as your question makes little sense in itself, I suspect this will only be useful to you to help you understand why your question was so little use.
Oct 23 '09 #3
Thanks Guys...both ideas worked well form me...Thanks Again.. :D
Oct 27 '09 #4
NeoPa
32,556 Expert Mod 16PB
Thanks for letting us know. That helps for people searching through threads for answers :)
Oct 27 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Marcin Kalicinski | last post by:
Hi, I found out that default constructor of std::complex class initializes the value to (0,0). I wonder why is it so? Because of this, the code below is about two times slower than it could be...
8
by: Steve Jorgensen | last post by:
Mailing List management is a good example of a case where my conundrum arises. Say there is a m-m relationship between parties and groups - anyone can be a member of any combintation of groups. ...
5
by: Glen Low | last post by:
Suppose I have a complex number as follows: double _Complex d; Can I access the real part as ((double*) d) and the imaginary part as
7
by: BS | last post by:
Hello everybody I'm calling a webservice that returns complex data. The goal is to populate a datagrid with it. Using a loop for each record found ( such as For i = 0 To...
4
by: techiepundit | last post by:
I'm a Python newbie who just started learning the language a few weeks ago. So these are beginner questions. I have a list of sockets that I use for select.select calls like this: ...
2
by: jccorreu | last post by:
I'm taking in data from multiple files that represents complex numbers for charateristics of different elements. I begin with arrays of doubles and interpolate to get standard values in real and...
0
by: Syn | last post by:
Hello, I'm getting this error while trying to build the stored procedure : create procedure sp_X_AccountDoc(in nDocID integer) begin declare szFuncName varchar(255); declare nfID integer;...
3
blyxx86
by: blyxx86 | last post by:
Hey there, I'm running into a slight problem today... I have a few things to show... I'm running into duplicate values being shown in my query, but I cannot use a "Select DISTINCT" as it...
23
by: Sacred Heart | last post by:
Hi, I'm new to Python and have come across a problem I don't know how to solve, enter com.lang.python :) I'm writing some small apps to learn the language, and I like it a lot so far. My...
9
by: hgrecco | last post by:
Hello, I am working on a program that must perform a certain task on numeric data stored in a file. The task is given by user input from a list of possible tasks. The file has some particular...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.