read index value of a control

  • Thread starter Thread starter Guest
  • Start date Start date
Alex,
I mean the index given to each control on a form, for example:

Me.Controls(5)

where the index 5 might be the index value of a text box "txtInput".

From the index, I can find the name of a control (Me.Controls(0).Name) but
how do I do it the other way round?

Many thanks
 
Try Me.Controls("controlName").index

Italian said:
Alex,
I mean the index given to each control on a form, for example:

Me.Controls(5)

where the index 5 might be the index value of a text box "txtInput".

From the index, I can find the name of a control (Me.Controls(0).Name) but
how do I do it the other way round?

Many thanks

:
 
Interesting! Why?

The plain search technique comes to mind (air code):

function getControlIndex(cName as string)as long
dim i as long
for i=0 to controls.count
if controls(i).name=cname then
getcontrolindex=i
exit for
endif
next
end function
 
Back
Top