Results 1 to 4 of 4
  1. #1
    Duncan is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Oct 2010
    Posts
    71

    Changing text box back colour

    G-day


    New to access and recently developed a successful database for work analysing KPI results etc. Now just for a learning experience re: analysing LOTTO results, I want to develop a form to changes the back colour of a text box when the number in it is the same as one entered in another text box (so I have a static unchanging 18 rows of 6 numbers in each in a table and one row of six numbers that change each week depending on the LOTTO draw and are entered in via text boxes on the form]. I can do this with;

    Dim Num1 As Long
    Num1 = Me.No1 (No1 = first weekly drawn number)
    If Me.n1 = Num1 Then (n1 = column one of the 18 rows)
    n1.BackColor = vbGreen
    End If

    My lotto card is 18 lines long and I have used a continuous form to have all the 18 lines load into the form from a table. So when I put the first drawn number into Me.No1 text box and if it matches the first number in the first row of Me.n1 text box the whole 18 rows change colour instead of only the ones that match Me.No1. Any help would be welcome.

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    I'm having a little trouble following your explanation, but when you change the Formatting of a Control in one Record, on a Continuous View Form, you're Formatting that Control in all Records! That's how Continuous View Forms work...unless...you use Conditional Formatting off of the Menu/Ribbon!

    In Form Design View

    1. Right-Click on the Control to be Formatted
    2. Click on Conditional Formatting
    3. Going thru the boxes, from Left-to-Right
    4. Under Condition1 select Expression Is
    5. In the 'conditions box' to the right, enter [n1] = [Num1]
    6. Use the icons to set your Formatting (the 'paint bucket' controls the Back Color)
    7. Click on OK

    Note that the Square Brackets around the Control names are mandatory, in Conditional Formatting.

    Now only the Control on the matching Record should change color, if I understand you correctly.
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Duncan is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Oct 2010
    Posts
    71
    Excellent works like a charm. And to think I spend a few hrs on a Saturday night using VB to figer it out. I did attemt to use Conditional Formatting in the first instance but it did not work.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to turn the format of a textbox back to text?
    By opopanax666 in forum Programming
    Replies: 2
    Last Post: 11-29-2012, 08:33 AM
  2. Replies: 4
    Last Post: 05-21-2012, 08:21 AM
  3. Changing the colour of a cell?
    By WayneSteenkamp in forum Access
    Replies: 3
    Last Post: 03-08-2012, 10:12 AM
  4. Changing Text colour on value amount
    By stu_C in forum Forms
    Replies: 1
    Last Post: 08-08-2011, 06:58 AM
  5. Replies: 0
    Last Post: 03-25-2011, 03:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums