473,480 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to change the state of a textbox depending on variable

6 New Member
I hope somebody can help...

I have a textbox that allows a date to be entered.
This date is checked with the code below and the background colour is changed if the date is overdue from white, yellow or red (depending on weeks)

Expand|Select|Wrap|Line Numbers
  1. Dim DateDifference As Integer
  2. DateDifference = DateDiff("ww", ApplicationDate, Date)
  3.  
  4. ApplicationDate.BackColor = Switch(DateDifference >= 7, vbRed, (DateDifference >= 5 And DateDifference < 7), vbYellow, DateDifference < 5, vbWhite, DateDifference = 0, vbWhite)
  5.  
This works well but as it is in the AfterUpdate function of the textbox, when the user goes to another record the colour of the textbox remains the same as the previous, until the textbox is edited. I want this to be calculated when a record is displayed AND/OR when it is edited.

Is there a way of refreshing/requering the code, or putting it somewhere else aswell?

Thanks
Nov 1 '10 #1
2 1720
jimatqsi
1,271 Recognized Expert Top Contributor
Nick, use conditional formatting. In design mode, select the text box you want and then on the Formatting menu you will find "Conditional Formatting." That will do just what you want.

Jim
Nov 1 '10 #2
Nick H
6 New Member
Thank you, can't believe it was that simple!
Nov 1 '10 #3

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

Similar topics

1
1658
by: Jamey Saunders | last post by:
Hi all, I'm just learning Python (I'm about 8 hours in so far), and I have a problem. I'm writing a small Windows app using Tkinter. I have two buttons on my screen that I want to start in an...
0
1286
by: Lupina | last post by:
How to Bind textbox control with public (string) variable? eg: String *msg; with TextBox * txtBox; Lupina
3
1374
by: luna | last post by:
is there a way of changing the state of a drop down list to a text box depending on criteria ? i could create a drop down list and a text box list in the same posistion and change the visibility...
0
986
by: DJDev | last post by:
Hi, I am in the process of building an app using ASP.NET wih VB.NET . We have a administration module using which the administrator of the application should be able to control which fields...
3
963
by: ton | last post by:
How can I in VB.NET set the width of a label or textbox depending on the length of the string and/or the font size. In my control I'm showing a textbox in a tablecell, which is added to a table...
6
4395
by: Rudy | last post by:
Hi all, I know this is easy, just can't seem to get it. I have a windows form, and a text box, with a value already in it. I need to add that value to a table. It's just one value, so the entire...
1
3064
by: Luqman | last post by:
The detailview control is combination of textboxes and labels, while detailview is in edit mode, how can I change the textbox value through code ? For example: My detailView has following...
2
2761
by: JLC | last post by:
Hi, I am creating a page in asp.net that has a checkbox and a textbox. When the checkbox is checked I want the textbox to become active and show text. If the checkbox is unchecked, I would like...
3
1165
by: harig | last post by:
hi all.. how do i focus a textbox from a javascript i'e) <input type="text" size='50' name="txt1" maxlength='254' value="" onblur="checkDir()"> <input type="text" size='50'...
0
914
by: AAaron123 | last post by:
In an asp.tablecell I have a textbox. The row has two cells. Sometimes the textbox is the tallest and sometimes the other cell is the tallest. When the other cell is that tallest I like to...
0
7044
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7087
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...
1
6741
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6944
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...
0
4483
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...
0
2995
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...
0
2985
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
182
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...

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.