Date Value Empty

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that shows a date field. When the date field is empty (null),
how can I change the fill color on form to another color. Build expression
for null value?
 
There are a couple of ways this can be accomplished. One would be to use
Conditional Formatting. In form design mode, select the control you want to
format, and from the menu bar select Formt->Conditional Formatting.
The other would be to use the Form's Current event to set the back color:
If IsNull(Me.MyDateControl) Then
Me.MyDateControl.BackColor = 'Put your color here
End If
 
I am trying to use conditional formatting and have condition 1 as follows:
field value is; equal to; IsNull;change back fill to read. This is not
working. How do I complete this using conditional formatting?
 
IsNull is a function, not a value. I did try field value is; equal to; Null
and that did not work. I also tried field value is; equal to; "" and that
did not work either.
It would probably work better if you use the other method I posted earlier.
 
I do not have the knowledge to create color change on form through Current
Event. Can you walk me through the process or suggest another solution via
conditional formating.
 
Open your form in design mode.
Click on the Properties icon on the menu bar
Select Form in the combo box at the top of the Properties dialog
Select the Events tab
Click in the text box for On Current
Click the icon at the right with the 3 periods ...
Select Code Builder
Paste the following code:

If IsNull(Me.MyDateControl) Then
Me.MyDateControl.BackColor = vbRed
End If

Then to complete the process so that it goes back to the normal color after
a date is entered, Do the same as above except that instead of On Current,
select After Update and paste in this code:

If IsNull(Me.MyDateControl) Then
Me.MyDateControl.BackColor = vbRed
Else
Me.MyDateControl.BackColor = vbWhite
End If
 
This worked. One more question on another date field I want a default value
of 00/00/0000. How can I do this.
 
Using your coding inside a report I get a compile error. It can't find
..MyDateControl. Any thoughts
 
Yes, the naming I used was just for example purposes. You need to change the
literal .MyDateControl to whatever the name of the text box is where you
enter the date. If you have already done that, then it is a reference
problem. If you are referencing a control on a form from within a report,
you have to fully qualify the name.
forms!PutYourFormNameHere!PutYourDateControlNameHere
 
Back
Top