Date Calculation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Like a few others I have created a form from a table and an expression to
calculate future dates both 6 and 12 months out. However, I need to have the
calculated dates saved in the table. How do I do this?
 
Like a few others I have created a form from a table and an expression to
calculate future dates both 6 and 12 months out. However, I need to have the
calculated dates saved in the table. How do I do this?

You probably don't need to save them in a table.

Whenever you need those dates in the future, simply recalculate them,
using that same expression you now have.
 
I have to have those dates saved. They must show up automatically in a
report, without them saved or inputed in the table I can't get them to show
up on the report. Is there another way to do this? The databse is for
tracking weapons qualifications and all info must be saved for legal
purposes. I am trying to have the dates change automatically to "dummy
proof" the tracking and management of the qualifications.
 
Dom,

Use an update query to update the table for the future dates of 6 and 12
months, based on the unbound control that calculates the future dates. You
could add this event to a record save command button, or assign it to it's
own button. If your form name is form and the unbound control names are
sixmonth and twelvemonth then the update query would have a statement that
looks like this in the update criteria of the query.
[forms]![form].[sixmonth] for the six month update.

You could also just calculate the date on the report without storing the two
future dates. Just add two unbound controls and make the recordsource the
record date plus the number of days to the future date. Example:
=([recorddate]+180) where recorddate is the name of the date field and 180
represents the number of days in the future to be displayed in the report.
 
Because you are using a form, you can use the 'BeforeUpdate'-event.
Before the current (changed) record is saved, you have time to adapt
values. So:

sub MyForm_BeforeUpdate(.....)
me![calculated_field1] = my_calculation(me![base_field],6) ' add 6
months
me![calculated_field2] = my_calculation(me![base_field],12) ' add 12
months
end sub

Where calculated_field1 and calculated_field2 are the fields that need
to be calculated and saved using the function me_calculation.
Parameters for the function are you base-field with the date, and a
parameter... only guessing of course how the function works.

Hope you get the trick. How to create an event-procedure? Select
FORM-properties, select tab 'EVents' and look for the correct event.
Press the button (with three dots) behind it, and let MSA generate a
event-procedure for you (hence the ..... in my code: MSA will generate
it)>

Good Luck
 
And for yet another alternative, add the dates as computed fields in a
query, and use that query as the basis for the report.
 
Dom said:
I have to have those dates saved. They must show up automatically in
a report, without them saved or inputed in the table I can't get them
to show up on the report. Is there another way to do this?

Put the calculations in the report.
 

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


Back
Top