Results 1 to 8 of 8
  1. #1
    gunterhoflack is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    10

    changing background multipleform

    I would like change the color of the background of the detail of a continuous form, recording to the value I have in a textbox ...; Is this possible

    for example: value : gren ==> background must be green
    value = geel ==> background must be yellow .....

    How can I do this through programming ??
    Click image for larger version. 

Name:	forumaccess.jpg 
Views:	11 
Size:	40.1 KB 
ID:	10710

  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
    You can't do this with a Textbox, you need to be able to limit the Values entered to those you have programmed for, spelled correctly. A simple way would be to create a Combobox, entering the Plain Language Names for the Colors.

    Then, in the AfterUpdate event of the Combobox use something like this, using the VBA Constants for Colors:

    Code:
    Private Sub ComboName_AfterUpdate()
     
     Select Case ComboName
    
     Case "Red"
       Me.Detail.BackColor = vbRed
     
     Case "White"
       Me.Detail.BackColor = vbWhite
    
     Case "Blue"
       Me.Detail.BackColor = vbBlue
     
     End Select
    
    End Sub


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

    All posts/responses based on Access 2003/2007

  3. #3
    gunterhoflack is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    10
    Quote Originally Posted by Missinglinq View Post
    Create a [B]Combobox, entering the Plain Language Names for the Colors

    Then, in the AfterUpdate event of the Combobox use something like this, using the VBA Constants for Colors:

    Code:
    Private Sub ComboName_AfterUpdate()
     
     Select Case ComboName
    
     Case "Red"
       Me.Detail.BackColor = vbRed
     
     Case "White"
       Me.Detail.BackColor = vbWhite
    
     Case "Blue"
       Me.Detail.BackColor = vbBlue
     
     End Select
    
    End Sub


    Linq ;0)>
    Hello I don't think this is a solution because this is a continu form. And the value , red, white, blue, are fields coming from a query .... so the backcolor should different for every line in the form ......
    I don't know on which event event I should do it.
    I should use case panelcolour.value and that in a case statement, but I don't know which event I could use for a continuous form

    greetz.
    gunter

  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
    Sorry, but I know of no way to set the BackColor of a Form's Detail Section, on a Continuous View Form, so that it changes on a Record-by-Record basis. There is only one Detail Section, and what it's set to is what it's set to!

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

    All posts/responses based on Access 2003/2007

  5. #5
    gunterhoflack is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    10
    Quote Originally Posted by Missinglinq View Post
    Sorry, but I know of no way to set the BackColor of a Form's Detail Section, on a Continuous View Form, so that it changes on a Record-by-Record basis. There is only one Detail Section, and what it's set to is what it's set to!

    Linq ;0)>
    Could it be solved by adding a rectangle, and change its color, record by record based on the value of the colour ??

    but which event should I use ?

  6. #6
    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
    No, Rectangles are Unbound Controls, and the same rule applies; the Rectangle on all Records is going to be formatted the same as the one on the Current Record.

    Doing almost any kind of formatting in a Continuous Form requires using the Conditional Formatting Wizard; it cannot be done in code, using events. You could try something like

    1. Placing a Textbox, under all of the Controls.
    2. Bind it to a Field in the underlying Table/Query
    3. Leave it unpopulated
    4. Send it to Back
    5. Right Click on the Textbox
    6. Click on Conditional Formatting
    7. Under ConditionX, select Expression Is
    8. In the next box enter: [YourFieldName] = "Green"
    9. Use the BackColor Icon (looks like a bucket of paint) to select Green from the Palette
    10. Hit 'Add'
    11. Repeat Steps 7-10 for each color
    12. When completed, hit 'OK'


    I've seen this done, but never thought it looked very professional, to be honest. But, as they say in the ads, your results may vary! And in Access 2010, I believe you now have the ability to set 50 Conditions, a huge improvement over the old limit of three plus a default condition!

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

    All posts/responses based on Access 2003/2007

  7. #7
    gunterhoflack is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    10
    Quote Originally Posted by Missinglinq View Post
    No, Rectangles are Unbound Controls, and the same rule applies; the Rectangle on all Records is going to be formatted the same as the one on the Current Record.

    Doing almost any kind of formatting in a Continuous Form requires using the Conditional Formatting Wizard; it cannot be done in code, using events. You could try something like

    1. Placing a Textbox, under all of the Controls.
    2. Bind it to a Field in the underlying Table/Query
    3. Leave it unpopulated
    4. Send it to Back
    5. Right Click on the Textbox
    6. Click on Conditional Formatting
    7. Under ConditionX, select Expression Is
    8. In the next box enter: [YourFieldName] = "Green"
    9. Use the BackColor Icon (looks like a bucket of paint) to select Green from the Palette
    10. Hit 'Add'
    11. Repeat Steps 7-10 for each color
    12. When completed, hit 'OK'


    I've seen this done, but never thought it looked very professional, to be honest. But, as they say in the ads, your results may vary! And in Access 2010, I believe you now have the ability to set 50 Conditions, a huge improvement over the old limit of three plus a default condition!

    Linq ;0)>
    tnx a lot this did the trick for me.......

  8. #8
    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 it works for you!

    Good luck with your project!

    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. Changing background image by date range
    By Monterey_Manzer in forum Forms
    Replies: 4
    Last Post: 09-27-2012, 11:52 AM
  2. Can a form run in the background?
    By polis in forum Forms
    Replies: 3
    Last Post: 09-11-2011, 06:06 PM
  3. Changing scrolling field background
    By JeffG3209 in forum Access
    Replies: 0
    Last Post: 05-10-2011, 08:56 PM
  4. Run DB in Background
    By jgelpi16 in forum Access
    Replies: 1
    Last Post: 07-27-2010, 01:50 PM
  5. background
    By marianne in forum Access
    Replies: 23
    Last Post: 05-03-2009, 02:10 AM

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