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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating calculated form field to TABLE

Status
Not open for further replies.

johnywest

MIS
Feb 19, 2003
15
US
Hi all,
I have a calculated date field that once calculated will never change. I have the form set up to do the calculation based on entry in a prior date field. Now my problem is how do I get that calculated result into my table for that record? I have read in earlier posts that it's not recommended to do this but seeing how this date will never change I don't think it should matter, however if this is not the way to do it how could I create a query to show specific records based on the calculated date field. Man I think I confused myself on that one. Maybe this will help.

Datefield1 =begin test date
calcdatefield2= datefield1 +90 days

Question 1: How can I get this calcdatefield2 to update my table?

or
Question 2: How can I create a query based on the calculated date field?

It seems to me that updating the table would be simplest but I'm at a loss.


Thanks in advance
John
 
If you want to update a number of records at one time (and have a reliable way to identify the records to be updated), you could create an update query that would end up something like this, assuming MyTable is the table to be update, MyChoice is the field that contains the correct selection criteria (and should equal strWhichOnes), TableDate is the date field in the table to be updated, and me.DateField1 refers to the user entered date.

Dim strSQL as string

strSQL = "UPDATE [MyTable] SET [TableDate] = DateAdd('d', #& me.DateField1 & "#,90) WHERE [MyChoir] = '" & strWhichOnes & "'"

DoCmd.RunSQL strSQL



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top