Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    little code help (Access 2000)

    I use the code below to change the backcolor off all the text boxes on a form to the color white if the record is a new record. This works great except now they want one text box called Select_form on the form to not turn white. Is there a way to modify the code below to do this? Can the textbox called Select_form be excluded? Thanks.....

    If Me.NewRecord Then
    For Each ctl In Me.Controls

    If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
    ctl.BackColor = 16777215
    End If

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

    Re: little code help (Access 2000)

    If Me.NewRecord Then
    For Each ctl In Me.Controls
    If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox And Not (ctl.Name = "Select_form") Then
    ctl.BackColor = 16777215
    End If
    Next ctl
    End If

  3. #3
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: little code help (Access 2000)

    Hi, you can use the ctl.Name property to check

    Dim ctl As Control
    For Each ctl In Me.Controls
    If ctl.Name <> "Select_form" And (ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox) _
    Then ctl.BackColor = vbWhite
    Next ctl
    Thanks,

    pmatz

Posting Permissions

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