auto update form

P

Pass-the-Reality

I have two fields on my form - RevisonDate and ReviewDate. The default
value for RevisionDate is set to =Date(). This works fine. I then set the
default vaule for the ReviewDate to =[RevisionDate]+60. This ONLY works if I
manually type in the RevisionDate. I know I need a requery somewhere and I
have tried it on the form and different fields, but it is not working. Where
should I add the requery????? Or do I need to remove the default for
ReviewDate and just have code to populate the field on close? Not sure.
 
J

John Spencer

You can't use a default value that is based on a calculation of the value in
another field. You can use =Date() + 60 as a default.

If you want the value in ReviewDate to automatically be set to whatever is
entered in RevisionDate then you need to use VBA in the RevisionDate control's
after Update event.

Private Sub RevisionDate_AfterUpdate()
If IsDate(Me.RevisionDate) Then
If IsNull(ReviewDate) or ReviewDate =Date() +60 Then
Me.ReviewDate = Me.RevisionDate + 60
End if
End If
End Sub

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
S

surinder

sir,
please set =date(year,month,day) in revision date column, 60 in day allowed
column and set review date =revision date + day allowed. it will give the
desired result.
surinder
 
J

Jeff Boyce

If you have a date [RevisionDate], and you know that you next wish to review
that record in sixty days, why bother storing a calculated date?

Instead, you could simply use a query in which you add 60 days to the
[RevisionDate] to get an up-to-date (no pun intended) calculation.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 

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

Similar Threads

Union data 1
Filter between two dates 4
Report criteria 3
Search and delete records 2
Query criteria 2
Find and Delete existing records 1
Editing Existing records 12
Validation rule 3

Top