Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding days to a date field 1

Status
Not open for further replies.

Tobasco1136

IS-IT--Management
Jun 7, 2007
29
US
I am working on a database to check out files. I have a field DateFileCheckedOut, and DateFileDue. I would like to know how to add 30 days to the DateFileCheckedOut, and automatically add it to the DateFileDue field. I have tried DateAdd, but it didn't work the way I thought. Any ideas? Please don't put it in SQL or VBA as I am new.
 


Hi,

"...I have tried DateAdd, but it didn't work the way I thought...."

What did you try and what was the unexpected result?

Skip,
[sub]
[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue][/sub]
 
don't put it in SQL or VBA
So, what do you want ? An expression in the query grid ?
DateFileDue: DateFileCheckedOut+30

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Here's what you could do:

Create a Form with the two fields from your table, then in the form design mode, double-click on the DateFileCheckedOut text box. The properties window will open. Select the "Event" tag, then click on the "After Update" event. Click on the little button with the 3 dots which will pop up on the right. Select "Code Builder" from the "Choose Builder" pop up, then click "OK". The code window will open with the following:

Private Sub DateFileCheckedOut_AfterUpdate()

End Sub

Paste this code between these two lines.

DateFileDue = DateAdd("d", 30, DateFileCheckedOut)

This is what your code should look like after:

Private Sub DateFileCheckedOut_AfterUpdate()
DateFileDue = DateAdd("d", 30, DateFileCheckedOut)
End Sub

John
 
I thought maybe I could calculate the DateFileDue in the same table. I was just experimenting with the table design. Is there a way of adding 30 days to the DateFileCheckedOut date and have it autopopulate the DateFileDue?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top