PC Review


Reply
Thread Tools Rate Thread

default value for one field based on another

 
 
Tara
Guest
Posts: n/a
 
      5th May 2010
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.
 
Reply With Quote
 
 
 
 
Dorian
Guest
Posts: n/a
 
      5th May 2010
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.

 
Reply With Quote
 
Jon Lewis
Guest
Posts: n/a
 
      5th May 2010
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" <(E-Mail Removed)> wrote in message
news:85D22B69-A963-446C-BE4B-(E-Mail Removed)...
>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.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Default value of date field based on another Ed Cones Microsoft Access 7 18th Mar 2008 09:22 PM
Set the default value in a table based on a different field? =?Utf-8?B?S2FyZW5I?= Microsoft Access Database Table Design 1 8th Feb 2007 09:56 PM
Calculate default value based on another field =?Utf-8?B?QmVra2lN?= Microsoft Access Forms 1 18th Feb 2006 03:06 AM
Default Value of field based on another field of same record =?Utf-8?B?TmFyZXNoIEt1bWFyIFNhaW5p?= Microsoft Access Getting Started 5 24th May 2005 03:11 AM
Default values based on a field =?Utf-8?B?Qm9i?= Microsoft Access Forms 1 2nd Feb 2004 05:56 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:47 AM.