Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Jul 2003
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    check box/ enable and disabling a text box (Access 2000)

    Hello I am trying to set a text box enable property to true and False based on the check box see: example of code
    e.g1
    If Accept = Yes Then
    Me.FixID.Enabled = True
    End If
    e.g2
    If Accept = Yes Then
    Me.FixID.Enabled = True
    ElseIf Accept = No Then
    Me.FixID.Enabled = False
    End If

    Can you help please

  2. #2
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Richland, Washington, USA
    Posts
    407
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: check box/ enable and disabling a text box (Access 2000)

    If Accept is the name of your check box and FixID is the name of your text box then

    <font face="Georgia">Me!FixID.Enabled = Me!Accept</font face=georgia>

    should be all you need. (The <font face="Georgia">Me!</font face=georgia> prefix is optional but I like to include it to remind me, or someone else, that the form object is being referred to.) Your code should work, too, except that you should you "True" and "False" instead of "Yes" and "No" in the If statements.

    Be sure to put this code in your form's Form_Load event routine and the Accept check box's AfterUpdate event routine.

    Hope this helps.

  3. #3
    Lounger
    Join Date
    Jul 2003
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: check box/ enable and disabling a text box (Access 2000)

    Okay that will work(not properly) if I have the enabled property defaulted to No and once I check the check box it works but when I go th the next record the text box is no longer disabled and of course the checkbox is not selected.

    Sonya

  4. #4
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Richland, Washington, USA
    Posts
    407
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: check box/ enable and disabling a text box (Access 2000)

    Assign the initial conditions for a newly selected record in the form's OnCurrent event routine. For example if you want the text box disabled until the check box is checked:
    <font face="Georgia">
    Me!Accept = False
    Me!FixID.Enabled = False
    </font face=georgia>
    (If you do this then you don't need the code in the Form_Open routine.)

  5. #5
    Lounger
    Join Date
    Jul 2003
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: check box/ enable and disabling a text box (Access 2000)

    When I change record the the check loses it setting, I check the checkbox and go to next record and go back to previous record and the checkbox is no longer checked.
    (This is what I am doining)
    Private Sub Form_Current()
    Me!Accept = False
    Me!FixID.Enabled = False
    End Sub
    &
    Private Sub Accept_Click()
    Me!FixID.Enabled = Me!Accept
    End Sub

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: check box/ enable and disabling a text box (Access 2000)

    If you want the status to be stored with the record. the check box must be bound to a Yes/No field in the table underlying the form.

    If that is the case, the code in the On Current event should be the same as in the On Click event of the check box:

    Private Sub Form_Current()
    Me!FixID.Enabled = Me!Accept
    End Sub

    As you move from record to record, the check box will reflect the status as stored in the table, and the On Current event handler will enable/disable FixID according to this status.

Posting Permissions

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