Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Control Type.

Status
Not open for further replies.

Ed2020

Programmer
Nov 12, 2001
1,899
GB
Is there a VB function that returns the control type?

Ed Metcalfe.
 
Yes. Check out the CONTROLS collection. You can enumerate all the controls within an object, and by setting s variable of type CONTROL, examine it's properties such as type, name, value, etc etc..

 
I'm perhaps missing something obvious but as far as I can see a Control type object variable does not have a .Type property.........

Ed Metcalfe.
 
Hmmmm...... thanks for that, but why isn't ControlType in the list of properties for the object variable?? It works, but how are you supposed to find it if it ain't listed??

Ed Metcalfe.
 
Hmmmm back..there's a full page in the Help system on CONTROLTYPE, including an example that iterates through all the controls on a form and changes some of their properties.

To return the TYPE of a control, you should be able to just query it:

Dim f as form, c as control, t as string

set f = Forms!MyForm
Set c = f.TxtName

t = c.Controltype

"t" would now be set to "acTextBox"

Jim Hare
"Remember, you're unique - just like everonone else"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top