Access Form Control Nos vs acTypeNAme

gray

Registered User.
Local time
Today, 19:08
Joined
Mar 19, 2007
Messages
578
Hi

Anyone know how to correlate control-type numbers to the ac-Type-Names please ?

e.g.

the ControlType of a textbox is 109...
the "actypename" is acTextbox

but what is a ControlType of 123?

I know TypeOf can help in a case statement where one already knows all the actypes but I need to do a:-

msgbox Screen.PreviousControl.ControlType to return "acTextBox","acCombobox" rather than 109,123 etc...

I must have found this at some stage but I can't remember how I did it.

Thanks
 
I don't think there's a ControlType collection, just an enumaration. You will need to construct your own. A comprehensive list is in Help. Just type in acControlType in Help and you will see the full list.
 
I know of no list giving the Numeric Values, but in any Code Module you can press <Ctrl> + <G> to pop up the Immediate Window and then find the Numeric Value by entering

?acControlName

and pressing <Enter>. You should be aware, though, that using the Numeric Values is not advised! Although the Intrinsic Constants remain the same, from one version to another, the Numeric Values can and do change, and so are specific to the version you're working in. If you use the Numeric Values and sometime in the future start running your app in another version of Access they may not work as you expect.

The whole point of the Constants is to have a name that easy to remember, as opposed to trying to remember Numeric Values. Why do you want to take this approach?

Linq ;0)>
 
Hi

Thanks for the info.

Actually, it's the acTypeName constants that I want to use.. Not the numerics.

I'm looping around a form and modifying control labels. During that loop I take actions based on the acTypeName and I was trying to find out what a main Tab Control is called in terms of acXXXXX... acTabControl? acPageTab? acMainTab?

I've met this on the Access battlefield before and it's a pain... Access itself returns the numeric value during the loop... utterly meaningless.... you'd think it would be straight forward to convert that to the name constant or there would be a matching list somewhere...

EDIT: Thanks gents... just found it in help as advised.... it's acTabCtl.. cheers
 
Like I mentioned in my post, Control Type is an enumeration, not a collection so there's no in-built method of converting the numeric value to its string representation without creating your own function.

I also mentioned that the full list of control types - roughly 15 - is in the Help files.

What is wrong with:
Code:
for each ctl in Me.Controls
    Select Case ctl.ControlType
        Case acTextbox
            ... do something
        Case acLabel
            ... do something
        Case acCheckbox
            ... do something
    End Select
next
... so on and so forth.
 
Hi

I am sorted now thanks (see edit of my last post)...

What is wrong with: xxxx xxxx xxxx etc
Absolutely nothing chap! :)... In fact it's precisely what I was trying to do but didn't have the full list of acXXX... type names. I now know (thanks to your post) that they live in the help files... I've made a note in my code this time...

cheers
 
Good to hear! :)

Just fyi gray, apart from the help files there's F2 as well which is even more comprehensive when it comes to giving you a full list of members/constants. The only thing is there's little or no explanation.
 

Users who are viewing this thread

Back
Top Bottom