Calculated Fields and increments

為{幸葍}努か 提交于 2019-12-25 00:57:36

问题


I am building a system using Starting Point and need help with calculated fields.

Basically when an estimate is created it takes the same ID as the project its linked to with a "-1" 1 being incremental value. So if the increment -1 exists the next estimate for that project would be -2 and so on.

So for example

Project Id: 120000

First Estimate: 120000-1

Second Estimate: 120000-2

I have found out how to add a hyphen and number after the project ID (the stored as estimate ID) like so id_project & "-" & 1 but I have no idea using filemaker how to use calculated fields to look and see if 120000-2 is a thing and if it is make it 120000-3

Any help greatly appreciated


回答1:


I'm assuming you have at least a relationship between Projects and Estimates. Perhaps something like this (without the Estimates_self table occurrence, which I'll get to in a moment):

If you're in the Projects context (on a layout linked to the Projects table), you can get a count from there using something like Count ( Estimates::id ).

If you want to make this happen from the context of Estimates, create a self-join as shown above, using the project foreign key as the match field. Then you can use Count ( Estimates_self::id ).

Finally, an option without any relationship graph changes would be to use ExecuteSQL:

ExecuteSQL (
  "SELECT COUNT(*) FROM Estimates WHERE project_id = ?" ;
  "" ; "" ;
  Estimates::project_id
)

All of these will give you the number of estimates that a given project has. Add one to that and you have your suffix number for the new estimate.




回答2:


Count the related estimates based on a parent Project. This will give you the Estimate number after dash



来源:https://stackoverflow.com/questions/47472956/calculated-fields-and-increments

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!