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. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 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

  4. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,326
    Thanks
    1
    Thanked 12 Times in 12 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.

  5. #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

  6. #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

  7. #6
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,326
    Thanks
    1
    Thanked 12 Times in 12 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.

  8. #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
  •