Connecting Tech Pros Worldwide Forums | Help | Site Map

Trouble updating a table using a calculated field via dateadd function...

Newbie
 
Join Date: Jul 2007
Posts: 22
#1: Jul 11 '07
I am having problems trying to update a field in a database using a field in a form. I currently have two fields, Today and Tomorrow in a table named Date. The Today field automatically defaults to the current date, and what I am trying to accomplish is if this date changes, then the second field, Tomorrow, will automatically become equivalant to the value of Today +1. Sounds simple enough, however I cannot get the table to update. I am able to get the form to update by using a calculated field. I read that since this was a calculated field that it was not bound to the table and that I should use the after update field on the event tab in Today's properties to set the value of the field, Tomorrow. I also am trying to use the dateadd function in order to accomplish. I am using Access 2003 and so far I have not been successful in putting the correct syntax. I have surfed for a while now and so far I have not found anything that seems to work. Right now I only have one table with two fields to keep it simple.

1 table named Data containing two fields: Today and Tomorrow
Today = defaults to the current date
Tomorrow = value of Today + 1

If anyone has ideas of where I can find an example of syntax, i would appreciate it!!!!
Thanks!

missinglinq's Avatar
Moderator
 
Join Date: Nov 2006
Location: Richmond, Virginia USA
Posts: 3,000
#2: Jul 11 '07

re: Trouble updating a table using a calculated field via dateadd function...


Expand|Select|Wrap|Line Numbers
  1.  Private Sub Today_BeforeUpdate(Cancel As Integer)
  2.   Tomorrow = DateAdd("D", 1, Today)
  3. End Sub
  4.  
Good Luck!

Linq ;0)>
Newbie
 
Join Date: Jul 2007
Posts: 22
#3: Jul 11 '07

re: Trouble updating a table using a calculated field via dateadd function...


Thank you so kindly. That definitely helped me get where I needed to go. Thanks again!
missinglinq's Avatar
Moderator
 
Join Date: Nov 2006
Location: Richmond, Virginia USA
Posts: 3,000
#4: Jul 11 '07

re: Trouble updating a table using a calculated field via dateadd function...


Glad we could help!

Linq ;0)>
Reply