I am currently working on a mapper to map excel sheets exported from one db and copy them to and excel sheet to import into another db.
I and creating buttons for each used column in my active sheet.
For Each field In rngFields
If field.Value <> "" Then
lngNextTop = lngNextTop + cTextBoxHeight + cGap
Me.Height = lngNextTop + lngTitleBarHeight
LB = "Label" & formcount
Frame1.Controls.Add bstrProgID:="Forms.Label.1", Name:=LB, Visible:=True
Frame1.Controls(LB).Left = 5
Frame1.Controls(LB).Top = lngNextTop + 5
Frame1.Controls(LB).Width = cTextBoxHeight
Frame1.Controls(LB).Width = cTextBoxWidth
Frame1.Controls(LB).Caption = field.Value
cb = "ComboBox" & formcount
Frame1.Controls.Add bstrProgID:="Forms.ComboBox.1", Name:=cb, Visible:=True
Frame1.Controls(cb).Left = 175
Frame1.Controls(cb).Top = lngNextTop
Frame1.Controls(cb).Width = 175
Frame1.Controls(cb).Height = cTextBoxHeight
chb = "CheckBox" & formcount
Frame1.Controls.Add bstrProgID:="Forms.CheckBox.1", Name:=chb, Visible:=True
Frame1.Controls(chb).Left = 377
Frame1.Controls(chb).Top = lngNextTop + 5
Frame1.Controls(chb).Width = 10
Frame1.Controls(chb).Height = 10
tb = "TextBox" & formcount
Frame1.Controls.Add bstrProgID:="Forms.TextBox.1", Name:=tb, Visible:=True
Frame1.Controls(tb).Left = 175
Frame1.Controls(tb).Top = lngNextTop
Frame1.Controls(tb).Width = cTextBoxWidth
Frame1.Controls(tb).Height = cTextBoxHeight
Frame1.Controls(tb).Visible = False
originsheet.Activate
HeaderSelect
Frame1.Controls(cb).AddItem ""
For Each cell In Selection
Frame1.Controls(cb).AddItem cell.Value
Next cell
End If
What I would like is when the check box is checked to hide the combo box and show the text box, and when it is unchecked to reshow it. If you want to change it to a button that would be fine. I just would like to know if it is possible to add an onclick even to these dynamicly created form controls.
Thanks in advance!
Bookmarks