field value based on another field

strawberry

Registered User.
Local time
Today, 13:45
Joined
Apr 1, 2008
Messages
43
Hi, I am creating a database and one of my fields is called 'LogDate'. I have another field that is called 'follow-up date' and i want it to be the value of the 'log date' + 3 days.

I have tried using the 'default value' to automate this but it keeps erroring. I have managed to get the field to default to todays date + 3 by typing in 'Date()+3' and this works fine so i thought i could type in 'LogDate+3' but i get an error.

Please could somebody help me. Many thanks
Jane
 
You need to recognize that tables don't usually work this way. You are trying to put a computed field in a table. There are a couple of ways to do this.

First: If you define this from a form, put code in the form on the LostFocus event of the text box containing the LogDate, do a DateAdd function on it to create the date for the FollowupDate.

Second: Don't store anything. Instead, plan to use a query to get that information. For the LogDate, just show the literal date. For the FollowUpDate, try something like this (and you have to look up the syntax for DateAdd 'cause I can never remember it)

IIF( Nz([FollowupDate],"") = "", DateAdd( add 3 days to LogDate ), [FollowupDate])

There is also an IsEmpty function that might work for that first IIF argument (as opposed to making an expression), but I rarely use it in the particular type of databases found in my office.

In your forms, use the query rather than the table to drive the form. It's considered better to drive from queries anyway because you get better control over locks.
 
many thanks for your reply
 
Thanks for your reply. I am still a little confused. in my form, i have opened the properties box for my field 'followupdate'. do i add in some code in the 'default property'. i have tried adding in '=DateAdd("d",3,"LogDate) but it just errors.

Many thanks
 

Users who are viewing this thread

Back
Top Bottom