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
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 ......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)>
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
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
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 ?
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
- Placing a Textbox, under all of the Controls.
- Bind it to a Field in the underlying Table/Query
- Leave it unpopulated
- Send it to Back
- Right Click on the Textbox
- Click on Conditional Formatting
- Under ConditionX, select Expression Is
- In the next box enter: [YourFieldName] = "Green"
- Use the BackColor Icon (looks like a bucket of paint) to select Green from the Palette
- Hit 'Add'
- Repeat Steps 7-10 for each color
- 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
tnx a lot this did the trick for me.......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
- Placing a Textbox, under all of the Controls.
- Bind it to a Field in the underlying Table/Query
- Leave it unpopulated
- Send it to Back
- Right Click on the Textbox
- Click on Conditional Formatting
- Under ConditionX, select Expression Is
- In the next box enter: [YourFieldName] = "Green"
- Use the BackColor Icon (looks like a bucket of paint) to select Green from the Palette
- Hit 'Add'
- Repeat Steps 7-10 for each color
- 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)>
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