Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting value displayed in text box

Status
Not open for further replies.

mkell1

Programmer
Mar 20, 2003
15
US
I have a text box that is bound to a date value in a table. The field within the table is set to not except null values. The field is used to record the start time of a process. The default value in this field is 1/1/1900 12:00 PM. This indicates that the process has not yet begun. When this is the value within the field for a given record, I would like the text box that displays the start time to the user to display as an empty text box so the user can see that the process has not yet begun. I tried to do an IIF statement

IIf ( [PRBegTime] = #1/1/1900 12:00 PM#, "", [PRBegTime] )

in the Control Source of the text box, but I get #Error in the display when I use this in the text box that I want to check. If I modify this to use the end date field (which is a separate text box on the form), it works just fine.

My question is this: is it possible to have a bound field that displays based on field value, or will I need to have a separate bound text box that is hidden and update that text box based on the value entered into the text box containing the expression that determines whether the value is displayed or not?

I hope this is clear and I appreciate any feedback!
 
Asuming the text box has a white background:

Private Sub Form_Current()

If Me.daterec = #1/1/2004# Then
Me.daterec.ForeColor = 16777215
Else
Me.daterec.ForeColor = 0
End If

This may create other issues such as when you create a new record, and how your keyboard behavior is set.

Play with it.
 
How are ya mkell1 . . . . .
[blue] is it possible to have a bound field that displays based on field value[/blue]
A custom field yes, [blue]bound no![/blue]

Now, if you look at what your doing, you want to change a default date & time to a Null if the default value is present in the field! You also have to consider, if a user makes a mistake (wrong record) how would they know to put back [purple]1/1/1900 12:00 PM[/purple]?

Bear in mind, as soon as you change the Control Source from a table name to an equation, the control is no longer bound.

In any case, instead of beating your head against a wall with this, why not let [blue]Null[/blue] & null string [blue]""[/blue] represent [purple]1/1/1900 12:00 PM[/purple]?

Besides the fact that Null & Null Strings are easily detected and more user friendly in your case, this would solve the problem, and save you alot of [blue]mental calisthenics[/blue].


Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top