Results 1 to 4 of 4

Thread: Checkbox Help

  1. #1
    Join Date
    Sep 2004
    Posts
    5

    Unanswered: Checkbox Help

    I have created a checkbox on a form and when it is "checked" a textbox is enabled and when it is not the textbox is not enabled. My problem is that when I go to create a new record I want the textbox to be disabled. Right now, when I go to a new record the checkbox is not checked, but the text box is enabled. I've been messing with this thing for hours and cant figure it out.
    This is what I have now:

    Private Sub Mailing_Sent_Click()
    If Me.Mailing_Sent = 0 Then
    Me.Text54.Enabled = False
    Else
    Me.Text54.Enabled = True
    End If
    End Sub

    Thanks for any help

  2. #2
    Join Date
    Feb 2003
    Location
    Wichita,KS
    Posts
    44
    Try this.
    Code:
    Private Sub Form_Current()
    If Me.NewRecord = True then
       Me.Text54.Enabled = False
       End If
    Exit Sub
    End Sub

  3. #3
    Join Date
    Dec 2003
    Posts
    172
    Is this what you are trying to do?

    (see the programming behind the form)

    I set the default value of the checkbox (in the property window) to False so if the checkbox is Null on a new record you disable the textbox. I also used the NZ() function around the value of the checkbox in the code to ensure it always returns False if the checkbox has no value.

    I could have done this:

    mycheckboxvalue=Me.chkMyCheckbox

    If mycheckboxvalue=True then
    Me.txtMyTextBox.Enabled=True
    Else
    Me.txtMyTextBox.Enabled=False
    End If

    I saved a few steps and just set the Enabled property of the text box to the True or False value of the checkbox:

    Me.txtMyTextBox.Enabled=Me.chkMyCheckbox

    The checkbox is bound to the customer table so each record can have its own separate checkbox setting. If you don't bind it to a table, then the checkbox will stay the same no matter what record the form is moved to.

    You can of course use programming behind the form to set the value of the checkbox at the form load event to True or False, and you can also change the checkbox value along the way using programming.

    Hope this helps.

    Joe G
    Attached Files Attached Files

  4. #4
    Join Date
    Sep 2004
    Posts
    5
    Thanks so much to both of you, that was exactly what I was looking for.

Posting Permissions

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