473,544 Members | 2,299 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

backcolor change

lee123
556 Contributor
is it possible to change the backcolor of a text box certain color for instance
let say that a text box is formatted in currency and you wanted to make the color of the backcolor vbyellow if it's under a hundred dollars and if the currecy is over five hundred dollars you would make it another color and the final one is if it's over 1000 dollars another color. because i tried to do this in an (if statement) but everytime i did the first color would show (under 100 dollars) then when i did the over 500 dollars it would change. but how do you do it if it's over 1000 dollars because when i did it would be the color i have selected for the one (over 500 dollars)
Sep 1 '07 #1
3 1773
missinglinq
3,532 Recognized Expert Specialist
I've picked some arbitrary colors here for demonstration purposes. You can change them to whatever you want, of course. You need to change CurrencyField to whatever you actually call yours!
Expand|Select|Wrap|Line Numbers
  1. Private Sub CurrencyField_AfterUpdate()
  2. If CurrencyField < 100 Then
  3.  CurrencyField.BackColor = vbYellow
  4. ElseIf CurrencyField > 500 And CurrencyField <= 1000 Then
  5.  CurrencyField.BackColor = vbRed
  6. ElseIf CurrencyField > 1000 Then
  7. CurrencyField.BackColor = vbBlue
  8. Else
  9. CurrencyField.BackColor = vbWhite
  10. End If
  11. End Sub
Where exactly are you placing this code?

Linq ;0)>
Sep 2 '07 #2
lee123
556 Contributor
in the form itself (on current) i almost had it right but looking at your code i forgot somethings Like this line:

Expand|Select|Wrap|Line Numbers
  1. ElseIf CurrencyField > 500 And CurrencyField <= 1000 Then
i forgot to add the:

And (CurrencyField) twice

thanks for the info.

lee123
Sep 2 '07 #3
missinglinq
3,532 Recognized Expert Specialist
That's a common mistake! Glad we could help!

Linq ;0)>
Sep 2 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5956
by: Mike | last post by:
I would like to change the back color on a Text Box on a Access97 Form.... I have a formula in the text box that adds up in Currency... =+.... the format is this +$#,###.00;-$#,###.00 to show me wether the amount is negative or possitive... But I want to do the following: If the dollar amount is Negative, I want the BackColor to change...
2
8094
by: perspolis | last post by:
HI I created a user control and place some control on it. I need when I change BackColor of user control,Back Color of other controls also change.. I used foloowing code: public override Color BackColor { get{return this.BackColor;} set{ this.BackColor=value;
1
8584
by: MLM450 | last post by:
I am trying to create a button on a toolstrip that is used to select a color. After the user selects their color, a portion of the button's image is changed to that color (similar to the highlighter button in Microsoft Word). How can this be done? I tried making part of the button's image transparent and then changed the button's BackColor...
1
1143
by: Matt | last post by:
I'm having a problem when I place ASP:Textbox controls on a form. During design time the control's backcolor is set to white. When I run the project in debug mode or deploy the page to a test web server, the backcolor for some of the fields changes to yellow. I've reviewed the HTML and don't see anything in there that would change the...
6
3415
by: LU | last post by:
A)I build a datagrid based on a calendar date selection. B)When user clicks a button column on the datagrid I want to highlight this row. I use the code below to highlight the row. ***** CODE TO HIGHLIGHT ROW Sub Datagrid_ItemCommand(ByVal s As Object, ByVal e As DataGridCommandEventArgs) If e.CommandName = "ViewUnitRequest" Then...
1
4090
by: Firewalker | last post by:
I am attempting to change the backColor property on the previously instantiated buttons FROM a listbox_doubleClick event. I thought it would be something like this: If Me.Controls.Item(iSeatNumber).BackColor.Equals(Color.White) Then Me.Controls.Item(iSeatNumber).BackColor.Equals(Color.CornflowerBlue) 'End If
5
3421
by: Lumpierbritches | last post by:
Thank you in advance for any and all assistance. I have a group of checkboxes; when the female gender is checked, I would like to change the backcolor property to reflect (pink) and if the checkbox male is checked to change the backcolor property to lightblue. In Access it's Me.Detail.BackColor = (color) When I try BackColor.Color(Pink) I...
3
2418
by: senfo | last post by:
I developed a Windows control in VS 2005 that inherits from the PictureBox Control that adds the ability to select images in a Windows application. It is, however, experiencing a strange issue that I can't explain. One of the desired affects was to provide the ability to change the background color on images that were selected, as well as...
0
1257
by: Wolfgrin | last post by:
Hi, I have set up a report In Access 2003 where there are 2 check boxes I refer to to change the color of the Date of that record. That part is working. I also need to Change the color of the date feild when the date in the field is 3 days or more older. I am currently using the following code. Any Suggestions? Thanks In Advance, Ray
3
2254
by: windy | last post by:
I would like to change the backcolor inside the checkbox when the component is on focus, not the color of the text. Thanks a lot.
0
7373
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7717
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5306
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4930
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3427
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
993
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
677
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.