Pregunta

Is there a way to easily determine what Label is 'attached' to a particular ComboBox in Access?

When adding new ComboBoxes to a Form, a Label is automatically generated and linked to it. I would have thought that the Label's Parent would be the ComboBox, but this isn't the case - nothing shows at all when I Debug.Print the Parent (as apposed to the Form being the Parent of the ComboBox). They're definintely linked in some way, though, and I'm hoping there's an easier way to find which are related to eachother than the way I'm currently using:

Ensure that the Label and ComboBox end in the same number, then use that number as a variable when accessing the .Controls Property of the Form.

The reason I want to do this, is to use the Label's Caption when looping through ComboBoxes.

Thanks in advance!

¿Fue útil?

Solución

After a bit more searching I've found you can access it as follows:

Text0.Controls.Item(0).Caption

Where

  • Text0 is the name of the combobox
  • Item(0) is the Label.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top