Can't Trigger Event Procedure from a Checkbox created on the Fly.
I'm creating a checkbox on the fly in a form. I know that the checkbox
name will be CkBox1 so I already created the following event procedure. For some reason I can't get the event procedure to trigger when I click on the checkbox that was created. I'm sure that it has something to do with the fact that I'm creating procedure before the control is created, but I would imagine there has to be a way. And due to the fact that this form needs to be very dynamic, I can't really get away with just creating the controls and hiding/unhiding them. Any suggestions would be appreciated. Thanks, James Private Sub CkBox1_Change() If PackageForm.Controls("CkBox1").Value = True Then With PackageForm.Controls("TBox4") .Enabled = True .Locked = False .BackStyle = fmBackStyleOpaque End With Else With PackageForm.Controls("TBox4") .Enabled = False .Locked = True .BackStyle = fmBackStyleTransparent .Value = "" End With End If End Sub |
Can't Trigger Event Procedure from a Checkbox created on the Fly.
JGeniti wrote: I'm creating a checkbox on the fly in a form. I know that the checkbox name will be CkBox1 so I already created the following event procedure. For some reason I can't get the event procedure to trigger when I click on the checkbox that was created. I'm sure that it has something to do with the fact that I'm creating procedure before the control is created, but I would imagine there has to be a way. And due to the fact that this form needs to be very dynamic, I can't really get away with just creating the controls and hiding/unhiding them. Any suggestions would be appreciated. Thanks, James Private Sub CkBox1_Change() If PackageForm.Controls("CkBox1").Value = True Then With PackageForm.Controls("TBox4") .Enabled = True .Locked = False .BackStyle = fmBackStyleOpaque End With Else With PackageForm.Controls("TBox4") .Enabled = False .Locked = True .BackStyle = fmBackStyleTransparent .Value = "" End With End If End Sub |
All times are GMT +1. The time now is 12:08 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com