+ Reply to Thread
Results 1 to 2 of 2

Can't Trigger Event Procedure from a Checkbox created on the Fly.

  1. #1
    JGeniti
    Guest

    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


  2. #2
    JGeniti
    Guest

    Re: 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



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1