default value for one field based on another

T

Tara

I have a form with two date fields on it - Service Date and Posted Date.
Since in most cases the Service Date will be the same as the Posted Date, I
have the default value of Posted Date field set to the value of the Service
Date field by using the following expression in the default value property:
=[ServiceDate]. It's not working though and I'm not sure why.
 
D

Dorian

Try this in the AfterUpdate event of the first date:

Private Sub Date1_AfterUpdate()
If Nz(Me!Date1, "") <> "" And Nz(Me!Date2, "") = "" Then
Me!Date2 = Me!Date1
End If
End Sub

-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
J

Jon Lewis

How are you expecting it to work? A default value only applies to a new
record so does ServiceDate have a default value too? In this case just give
your PostedDate control the same literal default value as your ServiceDate
(although =[ServiceDate] should work too)

If you want the PostedDate to default to the ServiceDate after it has been
chosen then use the AfterUpdate event of the ServiceDate control to set the
PostedDate value.

HTH
 

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