vba - Calculate date in MS Access then write value to a field in a table -


following on this question, how go writing resulting date value field (deadline (25 wd)) located in form?

(the field located in form linked table.)

the real solution not store "calculation", use when , required. calculations belong queries not in tables. reason why best use in queries storing in tables using form method because, when dateopened changed deadline automatically updated. but happens if using form edit information. if editing date directly in table or using query update record, deadline not consistent.

however, if use query

select      dateopened,      addworkdays(25, dateopened) deadline       yourtable; 

this work based on dateopened, when query run. if gets changed in query (while open), deadline updated accordingly. loose flexibility when use form store calculations table.

that being said, need calculate based on field; suggest make use of afterupdate event of dateopened control.

private sub dateopened_afterupdate()     if len(me.dateopened & vbnullstring) <> 0          me.deadlinedate = addworkdays(25, dateopened)     else         me.deadlinedate = ""     end if end sub 

since control bound table, there no need run update code. automatically have deadline filled in.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -