Forum Discussion
Updating a field in a Form 1 using button in Form 2
The relational way is to NOT store DTR, and rather calculate it in a query.
Why? Because it depends fully on StartDate and ResolveDate, which ARE stored, and in a relational database we don't store data that is fully dependent on other stored data.
Why? Because if one field gets updated, the dependent field needs to be updated as well, and if that does not happen, we have illogical data.
So create a function that takes two dates and returns the number of business days between them. Let's call this function Fred for now. Put it in a Standard Module, and declare it as a Public Function.
Then in a query:
select [somefields], Fred(StartDate, ResolveDate) as DTR from [sometable];
- jiniistrawberiiJun 26, 2023Copper ContributorHi, thank you for the info, that did make sense. I actually do have a function that returns the number of working days between StartDate and ResolveDate, and this is the value that gets thrown into DTR. And yes, what you said is the problem that I have now haha.
If you don't mind, just a few clarifications on the query. What type of query would it be? Also, what is in [somefields]? I'm assuming [sometable] is the database I'm currently using.
Thank you!- Tom_van_StiphoutJun 26, 2023Iron ContributorThis is a SELECT query (as the first word in the SQL statement suggests :-)).
With [somefields] I mean you would select some fields to be returned by your select query.
With [sometable] I mean the table you select from (the one with StartDate and ResolveDate).- jiniistrawberiiJun 27, 2023Copper Contributor
OMG IT WORKED!! Well, I had to tweak it a bit, but at least I got it to work haha.
Thank you so much!!!