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

unknown property works

553 512MB
I have got this piece of code:

Expand|Select|Wrap|Line Numbers
  1. Dim Ctrl As Control
  2.  If Ctrl.ControlType = acCheckBox Then
  3.  
my question is when i try to reference Ctrl, i dont get an property box poped up - seems like Ctrl of Control type hasn't got any property called .ControlType - but the above code still works and i get no error !

is that property hidden somewhere.. are there any hidden properties at all?
Aug 8 '07 #1
6 2046
dima69
181 Expert 100+
I have got this piece of code:

Expand|Select|Wrap|Line Numbers
  1. Dim Ctrl As Control
  2.  If Ctrl.ControlType = acCheckBox Then
  3.  
my question is when i try to reference Ctrl, i dont get an property box poped up - seems like Ctrl of Control type hasn't got any property called .ControlType - but the above code still works and i get no error !

is that property hidden somewhere.. are there any hidden properties at all?
Well, not all properties are popped up in vb editor (not just the hidden ones).
To see hidden properties, go to Object Browser and check the "Show Hidden Members" option from the right click popup menu.
Aug 8 '07 #2
ADezii
8,834 Expert 8TB
I have got this piece of code:

Expand|Select|Wrap|Line Numbers
  1. Dim Ctrl As Control
  2.  If Ctrl.ControlType = acCheckBox Then
  3.  
my question is when i try to reference Ctrl, i dont get an property box poped up - seems like Ctrl of Control type hasn't got any property called .ControlType - but the above code still works and i get no error !

is that property hidden somewhere.. are there any hidden properties at all?
You have declared an Object Variable As Type Control, but you have not explicitly assigned it to an Object. Take a look at the following 2 code segments which work as they should.
  1. Loop through all the Controls on a Form and if the Control is a Check Box, print out its Name:
    Expand|Select|Wrap|Line Numbers
    1. Dim Ctrl As Control
    2.  
    3. For Each Ctrl In Me.Controls
    4.   If Ctrl.ControlType = acCheckBox Then
    5.     Debug.Print Ctrl.Name
    6.   End If
    7. Next
  2. Assign the Object Variable Ctrl to a Text Box named txtLastName and set its Background Color to a Random Number between 0 and 15 (possible values of QBColor() Function):
    Expand|Select|Wrap|Line Numbers
    1. Dim Ctrl As Control
    2. Randomize
    3. Set Ctrl = Me![txtLastName]
    4. Ctrl.BackColor = QBColor(Int(Rnd * 16))
  3. Let me know how you make out.
Aug 8 '07 #3
questionit
553 512MB
ADezii

Thanks for the code.

but again, even this code:
Ctrl.BackColor <- - BackColor is not a property of Ctrl, howcome its working.

I dont understand very well what you mean by 'i have declared an Object Variable As Type Control but you have not explicitly assigned it to an Object' ...

Ctrl is itself an object, why would i assign it to any other object?

Thanks

You have declared an Object Variable As Type Control, but you have not explicitly assigned it to an Object. Take a look at the following 2 code segments which work as they should.
  1. Loop through all the Controls on a Form and if the Control is a Check Box, print out its Name:
    Expand|Select|Wrap|Line Numbers
    1. Dim Ctrl As Control
    2.  
    3. For Each Ctrl In Me.Controls
    4.   If Ctrl.ControlType = acCheckBox Then
    5.     Debug.Print Ctrl.Name
    6.   End If
    7. Next
  2. Assign the Object Variable Ctrl to a Text Box named txtLastName and set its Background Color to a Random Number between 0 and 15 (possible values of QBColor() Function):
    Expand|Select|Wrap|Line Numbers
    1. Dim Ctrl As Control
    2. Randomize
    3. Set Ctrl = Me![txtLastName]
    4. Ctrl.BackColor = QBColor(Int(Rnd * 16))
  3. Let me know how you make out.
Aug 9 '07 #4
ADezii
8,834 Expert 8TB
ADezii

Thanks for the code.

but again, even this code:
Ctrl.BackColor <- - BackColor is not a property of Ctrl, howcome its working.

I dont understand very well what you mean by 'i have declared an Object Variable As Type Control but you have not explicitly assigned it to an Object' ...

Ctrl is itself an object, why would i assign it to any other object?

Thanks
  1. As you have displayed Ctrl, it is not an Object but a Object Variable pointing to an Object. The same concept as:
    Expand|Select|Wrap|Line Numbers
    1. Dim intCounter As Integer
    intCounter is not an Integer, it is just a Variable assigned as Type Integer and as of now does not equal anything.
  2. Once you assign Ctrl (Instantiate) to a specific Object, it not points to that Object as in:
    Expand|Select|Wrap|Line Numbers
    1. Dim Ctrl As Control
    2. Set Ctrl = Me![txtLastName]     'points to Me![txtLastName]
  3. BackColor is a Property of Ctrl but your are just accessing it the wrong way and it has to do with the specific Property Type, for instance:
    Expand|Select|Wrap|Line Numbers
    1. Ctrl.Properties("BackColor") = vbRed        'works fine
  4. Some Properties can be accessed by using the Dot (.) Syntax (Built-in) while others must be accessed via the Properties Collection for the specific Object.
  5. It is, in fact, very confusing.
Aug 9 '07 #5
questionit
553 512MB
Hey ADezii

Thank you very much !

  1. As you have displayed Ctrl, it is not an Object but a Object Variable pointing to an Object. The same concept as:
    Expand|Select|Wrap|Line Numbers
    1. Dim intCounter As Integer
    intCounter is not an Integer, it is just a Variable assigned as Type Integer and as of now does not equal anything.
  2. Once you assign Ctrl (Instantiate) to a specific Object, it not points to that Object as in:
    Expand|Select|Wrap|Line Numbers
    1. Dim Ctrl As Control
    2. Set Ctrl = Me![txtLastName]     'points to Me![txtLastName]
  3. BackColor is a Property of Ctrl but your are just accessing it the wrong way and it has to do with the specific Property Type, for instance:
    Expand|Select|Wrap|Line Numbers
    1. Ctrl.Properties("BackColor") = vbRed        'works fine
  4. Some Properties can be accessed by using the Dot (.) Syntax (Built-in) while others must be accessed via the Properties Collection for the specific Object.
  5. It is, in fact, very confusing.
Aug 10 '07 #6
ADezii
8,834 Expert 8TB
Hey ADezii

Thank you very much !
You are quite welcome.
Aug 10 '07 #7

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

Similar topics

1
by: Navin | last post by:
Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. hi, guys i have asp application running on iis 5.0 windows 2000 i use...
53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
7
by: Ivan Debono | last post by:
Hi, I keep getting an Unknown runtime error on line 3 below: 1 If oField.Type <> 136 Then 'adChapter 2 If Right(oField.name, 3) = "_id" Then 3 For Each...
3
by: Lance | last post by:
Hi, Sorry for the confusing subject, but here is what I am after: I am using the 'System.Drawing.FontStyle' object, and I would like the caller of the function to be able to decide when calling...
5
by: Lars-Erik Aabech | last post by:
Hi! Guess it's my day again.. Tried to deploy a test release of a new asp.net web today, and got a terrible error. The web is running swell on three development computers, but when it's copied...
9
by: Klaus Johannes Rusch | last post by:
IE7 returns "unknown" instead of "undefined" when querying the type of an unknown property of an object, for example document.write(typeof window.missingproperty); Has "unknown" been defined...
1
by: TARUN | last post by:
Hello All, I am facing problem regarding Atlas. I have install the AtlasSetup.msi in my .NET framework 2.0, and i open the new Atlas Website...... Let me first explain the my senario, I...
1
by: nelsonivan | last post by:
Hi, i'm trying to reference some objects using reflection and Late Binding accessing. The Object API to his methods it's easy to understand, and it's as "Object.Method" - aka....
4
by: omono84 | last post by:
I know that this should be rather simple but i seem to be missing a step to get it to work. and have been unable to find a solution on the net. The aim is that I click on the open button to find...
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
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.