473,387 Members | 1,517 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,387 software developers and data experts.

Error when testing condition of CheckBox

15
I have a short bit of code that is giving me an error. Here is the code:

Expand|Select|Wrap|Line Numbers
  1. Dim ctrl As Control
  2. Dim intCounter As Integer
  3.  
  4.     For Each ctrl In Me.Controls
  5.         If ctrl.Tag = "Math" Then
  6.             If ctrl.Value = True Then
  7.                 intCounter = intCounter + 1
  8.             End If
  9.         End If
  10.     Next ctrl
  11.  
The error I'm getting on Line 6 is:

Run-time error '438':
Object doesn't support this property or method

I'm pretty sure I know what the error is telling me, sort of (that ctrl.value doesn't make any sense and isn't allowed). What I don't know is how to make the determination as to the value property of a checkbox using this coding structure. Is it possible?
May 9 '16 #1

✓ answered by zmbd

Double check that none of your label controls have their tag values set to "Math"

If you insert:
Debug.print ctrl.name
Just after Line 4, run your code, when the code errors, select the debug option.
Once the VBE opens, press <ctrl><g>
The immediate pane will show the name of the controls that have been processed thru the loop. The last control in the list will most likely be the problem.

This is one reason why I will rename the controls from the default name to something useful such as "txt_Meaningful_Name" so that I know which control is giving the error.

Try the above, locate which control is failing and let us know what happens and we can go from there....

-z

3 975
zmbd
5,501 Expert Mod 4TB
Double check that none of your label controls have their tag values set to "Math"

If you insert:
Debug.print ctrl.name
Just after Line 4, run your code, when the code errors, select the debug option.
Once the VBE opens, press <ctrl><g>
The immediate pane will show the name of the controls that have been processed thru the loop. The last control in the list will most likely be the problem.

This is one reason why I will rename the controls from the default name to something useful such as "txt_Meaningful_Name" so that I know which control is giving the error.

Try the above, locate which control is failing and let us know what happens and we can go from there....

-z
May 9 '16 #2
MrYoda1
15
Perfect! I originally had the tag set in the label, too. When I removed the tags from that part of the control I thought I caught them all, but I had not. There were two I hadn't removed.

I'm glad to know the coding structure works because I can think of times when it will come in handy.

Much appreciated!!!
May 9 '16 #3
zmbd
5,501 Expert Mod 4TB
You will find that a lot of us use the tags for a ton of reasons.

I will usually check the control type when using a me.controls situation:
ControlType Property [Access 2003 VBA Language Reference]

The example code isn't too horrible here and the constants are enumerated... back when MS actually made useful reference sites :)

This way I can use the Tag for grouping, storage, etc...
May 10 '16 #4

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

Similar topics

1
by: Supra | last post by:
i got "system error" when saving to xml file. i am using checkbox1 control to xml. when user clicked checkbox and set to true and press btnOk to conform and save it to xml ...
2
by: Troglite | last post by:
I am attempting to research an error condition that I am experiencing with the Config Block in EntLib 1.0. I have an admin web page that I use to populate some config values. I then have a second...
1
by: bobby1041 | last post by:
Hi All! I am trying to make several fields in a HTML form validated, but only when a dynamic checkbox is selected. I am not sure how to do this. Here is a snippet of the dynamic checkbox...
0
by: Supra | last post by:
i got "system error" when saving to xml file. i am using checkbox1 control to xml. when user clicked checkbox and set to true and press btnOk to conform and save it to xml ...
3
by: holysmokes99 | last post by:
I get an error when I try to execute the following code using ADO.Net in VB.Net: conn.open sqlString="CREATE LOGIN test WITH PASSWORD = '1qaz2wsx'" command=new SqlCommand(sqlString)...
8
by: Ryan | last post by:
I've created and deployed a VB.Net 2005 Application. I have it set as a FullTrust (ClickOnce) application. The install point is on a network server. I did not run into this issue at all while...
0
by: gakhanna | last post by:
Hi, I am getting the following error when I tried connecting to Task Center. In task center I have scheduled daily incremental backup which also didnt ran. Here comes the Error which I am getting:...
2
by: desktop | last post by:
I get this error when I run my program: red_black_tree.cpp:188: error: no matching function for call to ‘std::less<MyObj<int::less(MyObj<int>&, MyObj<int>&)’...
0
by: Terry Reedy | last post by:
Devarajulu, Baskar (D.) wrote: asap3lib.py is not part of the stdlib, and the error message is not very informative. Look at line 320 and see what might trigger the error.
1
by: robin1983 | last post by:
Dear All, I got stuck in simple problem, I have a two php file one for registration form and one for to check and insert into the table. The problem is that when I get any kind error in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.