This will add an event for a button created at runtime
Code:Private WithEvents cmd As CommandButton Private Sub Form_Load() Set chkBox = Me.Controls.Add("VB.CommandButton", "Btn") Me!Btn.Move 0, 0 Me!Btn.Caption = "Button1" Me!Btn.Visible = True End Sub Private Sub cmd_Click() MsgBox "You pressed the button" End Sub




Reply With Quote