Results 1 to 7 of 7
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Text Box Properties (A2K)

    All text boxes on a form have properties set, ie. BorderColor = vbYellow, BackColor = vbBlue, etc.
    Is it possible to change all of the properties on all of the boxes for instance BorderColor = vbRed, BackColor = vbWhite based on the execution of a procedure, like New Record?

    Trust me, you do not want the long version of this question. I hope that the above is sufficient.

    Thanks in advance for any help on this,
    Cheers,
    Andy

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

    Re: Text Box Properties (A2K)

    You could put code in the On Current event of the form:

    Private Sub Form_Current()
    Dim ctl As Control
    For Each ctl In Me.Controls
    If ctl.ControlType = acTextBox Then
    If Me.NewRecord Then
    ctl.BorderColor = vbRed
    ctl.BackColor = vbWhite
    Else
    ctl.BorderColor = vbYellow
    ctl.BackColor = vbBlue
    End If
    End If
    Next ctl
    Set ctl = Nothing
    End Sub

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,328
    Thanks
    1
    Thanked 13 Times in 13 Posts

    Re: Text Box Properties (A2K)

    Yes, you can change the properties at any time. However, there is no global command to change the value of a property for all controls; you have to loop through the controls collection and make the change. Sample code:

    Dim ctl as control
    For each ctl in Me
    select case ctl.controltype
    case actextbox, aclistbox, aclabel, accombobox
    ctl.bordercolor = vbred
    ctl.backcolor = vbwhite
    next ctl
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Text Box Properties (A2K)

    Hans & Mark,

    Thank you both kindly for your suggestions. I did find a workaround that was nowhere near as streamlined as yours just to get the little @#$!% working, but I will definetly try both your approaches and let you know how I fared.

    Thanks again,
    Cheers,
    Andy

  5. #5
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Text Box Properties (A2K)

    Mark,

    One quick question.

    Where exactly would I insert this code?
    Cheers,
    Andy

  6. #6
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,328
    Thanks
    1
    Thanked 13 Times in 13 Posts

    Re: Text Box Properties (A2K)

    Depends on exactly when you want it to run. You'd probably put it in your form's Current event, such that it would run if Me.NewRecord=True.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  7. #7
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Text Box Properties (A2K)

    Thanks for taking the time, Mark. Will give this a try first thing tomorrow. As I mentioned, I did come up with workaround that does the job and I guess that's the main thing.
    Cheers,
    Andy

Posting Permissions

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