Date/Time not Showing in Form

M

MBurns

The following code works but the data does not auto populate in the other
field. If I tab through the field is then shows. What am I missing?

Private Sub Check41_Click()
If [Earnest Received] = -1 Then
[Earnest Received Date] = Now()
End If
If [Earnest Received] = 0 Then
[Earnest Received Date] = Null
End If
End Sub
 
J

Jeanette Cunningham

Hi MBurns,
use the after update event of the checkbox instead of its click event.

Private Sub Check41_AfterUpdate()
If Me.[Earnest Received] = -1 Then
Me.[Earnest Received Date] = Now()
Else
Me.[Earnest Received Date] = Null
End If
End Sub


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
L

Linq Adams via AccessMonster.com

Also note that

Now()

returns a date AND time! If there's a possibility that you may need to
compare the Earnest Received values with each other or against a current
date, in a report, for example, using Now() will make it more difficult.
Better to use

Date()

unless you absolutely need the time component.
 
M

MBurns

I'm still having the same problem. As soon as I click on the check box the
date/time does not display in the adjacent field. If I click out of the form
and then back in or tab to the field the data shows. What do I need to do
for it to show automatically when I check the check box? Do I need to change
something on the form?
 
J

Jeanette Cunningham

Sounds as though you need to save the data on the form before the date/time
shows.

Do you have the code on the after update of the checkbox - make sure it's
not on the after update of the form instead.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top