Set caption of label on code created form

  • Thread starter Thread starter Tony Vrolyk
  • Start date Start date
T

Tony Vrolyk

I am working to create a custom import module that allows field matching.
Another program we use has, an interface I like that I am trying to
reproduce. This is what I have so far.

On a main import form, the user indicates an xls file from which the import
will come. Excel file is imported to temporary, uniquely named table. A
datasheet form is created from code for the imported table. Text box control
are created for each field in the table. Labels are created and attached to
each text box with a name of "lbl" & control.name. Code is inserted into the
dblclick event of every text box to open a pop-up form. The datasheet is
displayed as a subform on the main import form.

The pop-up form contains a listbox which lists fields in the target import
query. The pop-up form is modal and appears screen next to the mouse curser
and has no border so it appears like a floating list box.

Now what I want to do is on dblclick of the list box, set the label caption
attached to the subform active control to match the selected field in the
list box. Once that has been done for every field in the subform, the users
will click a final import button which will assemble a sql string from the
field control sources and label captions to update and append the data to
the import query.

I can't seem to come up with a reliable way to set the label captions. I can
easily get the name of the active control on the subform, is there a method
to get the name of the attached label? Is there a way to 'assemble' a
control name (like manipulating a string) and refer to it as a control -
that is take the name of the text box and add "lbl" to the beginning?

Any ideas would be great.
Tony Vrolyk
 
Application.Screen.ActiveControl.controls(0).caption = "I am the caption of
the active control"
 
Application.Screen.ActiveControl.controls(0).caption = "I am the caption on
the active control"
 
Back
Top