Topic: Action trigger upon certain date

Hi everyone, MVD fans, I have a question.. have any of you programmed something to have a particular action based on the date?  Let me explain, suppose you have a button that's disabled on a form.  This button will become enabled to perform whatever action was
asigned to it, depending on a certain date that you set from the moment a record was entered.  Let's say a record was created today, everytime you open the database, it will check to see if the record has reached the particular date it was set for the button to become enabled (say 30 days), if has passed 30 days since the record was created then the button becomes enabled and you can perform whatever action was assigned to that particular button, for example calculate depreciation of a good.  Something like that.  If you have done anything like this and can show an example, I'd appreciate it.


Thanks!!

Re: Action trigger upon certain date

Hi,
Please see attached (using your example, there are some assets and when they are more than 365 days old, the option to enter disposal details becomes available).  I've hard coded it for 365 days but it's just as easy to make that dependent on the record itself (in your example, some assets might be disposed of after 1 years, some after 3 etc etc).
Obviously, it doesn't have to be a button that's enabled - it can be ANY object that can be placed on a form or, indeed, ANY property of that object (the one that is probably used more than any other is setting a cell's colour in a tablegrid depending on elapsed date, value threshold etc). 
Regards,
Derek.

Post's attachments

Attachment icon gonpublic action date.zip 338.52 kb, 389 downloads since 2018-07-29 

Re: Action trigger upon certain date

Thank you Derek, your example is great!  How about if I just want to calculate the depreciation of a fixed asset in a period of 30 days? I want to have a button on a form that becomes enabled after 30 days of the date the record in question was created.  Then after the user presses thsi button, it calculates de Depreciation of the asset  and shows the actual value at the end of the period.  I know I can probably use your example and change 365 days to 30 days but will this work the way I explained it here?  Thanks a lot, great help.

Re: Action trigger upon certain date

Hi Alex,
Have a look at the attached which does most of the things you mentioned (well, it should but I've not really tested it!).
There are 2 basic ways of approaching it - using a single table (which I've done because it was quicker) or using a second, related table which would hold details for each cycle of depreciation for each asset - it's probably the way to go if I were doing it 'for real'.
Each asset is set up with a purchase date, purchase price, depreciation rate and number of days between depreciation cycles.  After that, the main grid shows in red assets that are due to be depreciated and, when you select one, the 'depreciate' button is visible.  Click it and it automatically calculates the depreciation and deducts it from the asset book value.  It also calculates when the following depreciation date is due.
Once depreciation starts, I 'lock' some of the asset details (ie price, rate, date etc) otherwise it would invalidate depreciation that has already occurred.
Anyway, I'm sure you'll get the picture and hope you can use some of it in whatever project you have in mind.
Regards,
Derek.

Post's attachments

Attachment icon depreciation 1 table.zip 342.12 kb, 412 downloads since 2018-07-29 

Re: Action trigger upon certain date

Yes!  Exactly what I had in mind Derek, you hit it right on!  As always! - thanks so much for the example, I'll see how I can accomodate it to make a Depreciation Calculator of some sort.  Really great example. 

Cheers buddy!