Calculating a date field in form

gtford

Registered User.
Local time
Today, 12:09
Joined
Apr 3, 2002
Messages
16
I'm sure there is a simple answer to this, but I can't figure it out (obviously I'm new at this). Included in my form are three fields: ExDate, DaysOut and DueDate. I need to calculate the DueDate by adding the ExDate and DaysOut fields. I need the calculated DueDate to move into my data table in the DueDate field of the table.

Thanks.
 
Thanks, Jack. I had reviewed the DateAdd function, but wasn't certain how to use it in such a way that the calculated date would be reflected in the data table. I need the DueDate field bound to my DueDate field in the Data Table.

I also wasn't certain if the "number" part of the formula could be reflected as a field which contains a number.

For example, let's say my ExDate is 12/31/02 and my DaysOut is -160. I want the DueDate to be calulated by adding the DaysOut field and the ExDate field resulting in a DueDate of 7/24/02.

Thanks for your quick response to my first post.
 
Use the Form_BeforeUpdate event or something similar to plug the data into your table:
Code:
Private Sub Form_BeforeUpdate(Cancel as Integer)
    If Not IsNull(Me.DueDateField) Then
        Me.DueDateField = DateAdd("d",Me.ExDate,MeDaysOut)
End Sub

You could also use an Update Query to do a batch of records at the end of the day, instead of form by form. If you do it in the form, be sure you choose an event which will ALWAYS get triggered, or you'll end up with blanks.

HTH,
David R
 

Users who are viewing this thread

Back
Top Bottom