Results 1 to 12 of 12
  1. #1
    New Lounger
    Join Date
    Oct 2002
    Location
    Colbert, Georgia, USA
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Textbox Backcolor (Access97 SR-2)

    I have been asked to set a

  2. #2
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Textbox Backcolor (Access97 SR-2)

    Sounds like a good candidate for conditional formatting. Look in Access help for further info. I have not used this but it sounds appropriate.

  3. #3
    New Lounger
    Join Date
    Oct 2002
    Location
    Colbert, Georgia, USA
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Textbox Backcolor (Access97 SR-2)

    Hi Don:

    Thanks. I shall give it a try -- but it will have to wait until after Easter, now.

    don w

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

    Re: Textbox Backcolor (Access97 SR-2)

    Unfortunately for you, conditional formatting is not available in Access 97, it was introduced in Access 2000.

    If your form is a single form, it is relatively easy to mimic conditional formatting using event procedures; if it is a continuous form, it is more involved, but still possible. If you provide more details, we will be able to give specific advice.

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

    Re: Textbox Backcolor (Access97 SR-2)

    If this is simply 4 unbound textboxes on a form (not a continuous form) then there should be no trouble changing the backcolor of each individual textbox. I'd say you had a flaw in your "If" logic. Could you show the code you are using?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  6. #6
    New Lounger
    Join Date
    Oct 2002
    Location
    Colbert, Georgia, USA
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Textbox Backcolor (Access97 SR-2)

    April 12, 2004

    Good morning Hans and Mark:
    To respond to your request(s), the following is provided.

    The

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

    Re: Textbox Backcolor (Access97 SR-2)

    I would put the code in the On Current event of the form. See if that helps.

    BTW, you might use a Select Case statement here instead of lots of ElseIf's, and the built-in symbolic color constants:

    Private Sub Form_Current()
    Select Case Me.Text16
    Case Is > 200000
    Me.Text16.BackColor = vbWindowBackground
    Case Is > 190000
    Me.Text16.BackColor = vbGreen
    Case Is > 180000
    Me.Text16.BackColor = vbYellow
    Case Else
    Me.Text16.BackColor = vbRed
    End Select
    ...
    End Sub

  8. #8
    New Lounger
    Join Date
    Oct 2002
    Location
    Colbert, Georgia, USA
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Textbox Backcolor (Access97 SR-2)

    Good Morning Hans:
    Thanks for the response. It got me part-way, at least. I did both suggestions: I put the If statements in the On Current event, then because of the response, put the Select Case statements in the On Current event. In both cases all four textboxes turned red "immediately". Red is the "Else" line for both the If and Select Case statements.

    An observation: it appeared the backcolor was "red" before any data "appeared" in the textboxes. There was enough time between the two events for it to be discernible. Logically (I think), this sequence of events would seem to "explain" why the boxes are red: there is no data there yet.

    I removed the Select Case statements from the form On Current event and put them on an On Click event of a label. After doing this the backcolor of the four inventory textboxes is white when the form opens. By the time I click on the label there is data in each of the textboxes and the backcolor of each textbox changes to the "correct" color.

    Since the Select Case statements result in correct backcolor when initiated after data is visibly present, it seems I need to delay the Select Case action. I'm not sure what would be the best way to do this -- I could see looping through "something" for a short time, maybe looking for data in "one" of the textboxes, then initiating the "color" action. But I need some suggestions/help.

    I appreciate any help.

    don

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

    Re: Textbox Backcolor (Access97 SR-2)

    The sum function in the control source has not been evaluated when the On Open or On Current event fires. You could use the On Timer event as follows:

    Open the form in design view.
    Set the Timer Interval property of the form to 500 (that is in milliseconds, so corresponds to 0.5 second; you can experiment with smaller or larger values once you've got it to work.)
    Put the code for the BackColor in the On Timer event:

    Private Sub Form_Timer()
    Select Case Me.Text16
    Case Is > 200000
    Me.Text16.BackColor = vbWindowBackground
    ...
    ...
    End Sub

    The code will run every <Timer Interval> milliseconds, so the back color will stay up to date. If you're only interested in updating it when the form is opened, you can disable the On Timer event by setting the Timer Interval to 0 when it has run once:

    Private Sub Form_Timer()
    Select Case Me.Text16
    Case Is > 200000
    Me.Text16.BackColor = vbWindowBackground
    ...
    ...
    Me.TimerInterval = 0
    End Sub

  10. #10
    New Lounger
    Join Date
    Oct 2002
    Location
    Colbert, Georgia, USA
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Textbox Backcolor (Access97 SR-2)

    Hans:

    Thanks very much for the help. Implementing your last suggestion, and getting the result I wanted, proved to be a lot easier in the end than I had hoped it might be.

    It never occurred to me that the "backcolor" code could be put in a "timer" event like this. It works great. I have learned some more Access "stuff." I may get this operational yet. If I don't retire first (almost 75), I will have to transfer all this to 2000/XP. But that is another day.

    Its been a good day so far. Two "puzzles" in the database cleared up. Finalized the password problem this morning, also.

    Again, Hans, Thanks for the help.

    don

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

    Re: Textbox Backcolor (Access97 SR-2)

    Great to hear that!

    By the way, it is much easier in Access 2000 and up - as noted higher up, you can use conditional formatting there, so no code is needed at all.

  12. #12
    New Lounger
    Join Date
    Oct 2002
    Location
    Colbert, Georgia, USA
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Textbox Backcolor (Access97 SR-2)

    Hans:

    Maybe I need to change my "attitude"/perception and look forward to it.

    Again, Thanks for the help

    don

Posting Permissions

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