default value for one field based on another

  • Follow


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.
0
Reply Utf 5/5/2010 3:34:11 PM

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".


"Tara" wrote:

> 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.
0
Reply Utf 5/5/2010 4:04:01 PM

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

"Tara" <Tara@discussions.microsoft.com> wrote in message 
news:85D22B69-A963-446C-BE4B-B1EAA3F3C4AB@microsoft.com...
>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. 


0
Reply Jon 5/5/2010 4:07:07 PM

2 Replies
1332 Views

(page loaded in 0.013 seconds)


Reply: