Default Date Value Based on another date field (1 Viewer)

striker

Useless and getting worse
Local time
Today, 10:19
Joined
Apr 4, 2002
Messages
65
I have two date fields in a table DateRaised and ReviewDate.

The ReviewDate field should be filled at data entry, but this date may not be known at the time. What I want to do is add a default value of a review date six months hence in this field.

For information the DateRaised is not neccessarily the date the record was created.
 

pono1

Registered User.
Local time
Today, 02:19
Joined
Jun 23, 2002
Messages
1,186
Striker,

Experiment by putting code similar to this in the On Current Event of your form -- your form which must include a textbox (hidden or otherwise) for ReviewDate, a field in a table.

Code:
If me.newrecord = true then

	Me.txtReviewDate = dateadd("m",6,date)

End if

Regards,
Tim
 

striker

Useless and getting worse
Local time
Today, 10:19
Joined
Apr 4, 2002
Messages
65
I've tried various places for thst code but I cannot get it to work at all. Am I being particularly thick or is the code not right.
 

IMO

Now Known as ___
Local time
Today, 10:19
Joined
Sep 11, 2002
Messages
723
See if this works, place this code in the OnCurrent event of the form

Code:
Private Sub Form_Current()

If Me.DateRaised <> "" Then
Me.ReviewDate = DateAdd("m", 6, [DateRaised])
Else
Me.ReviewDate = ""
End If

End Sub

IMO
 
Last edited:

striker

Useless and getting worse
Local time
Today, 10:19
Joined
Apr 4, 2002
Messages
65
IMO,

Works a treat But, how do I get the change to show up on the form when the change is made and not only when you move between records.

Cheers.
 

IMO

Now Known as ___
Local time
Today, 10:19
Joined
Sep 11, 2002
Messages
723
You could put the code in the LostFocus event of the Me.DateRaised control, but remember when you need to edit the Me.ReviewDate control, don't let Me.DateRaised getfocus.Have it's settings as Enabled = No, Locked = Yes

IMO
 

striker

Useless and getting worse
Local time
Today, 10:19
Joined
Apr 4, 2002
Messages
65
Now I am completely confused.

Ho do I set that then.
 

IMO

Now Known as ___
Local time
Today, 10:19
Joined
Sep 11, 2002
Messages
723
Here's a quick example of what I mean.

IMO
 

Attachments

  • testa2k.zip
    16.1 KB · Views: 473

Users who are viewing this thread

Top Bottom