Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Using Tap Forms 5 › Linking a Value to a Pick List
- This topic has 7 replies, 2 voices, and was last updated 1 month, 2 weeks ago by
Brendan.
-
AuthorPosts
-
May 13, 2023 at 9:45 AM #49411
Tom SeputisParticipantI have a use case of creating some maintenance logs for several items. An example is routine maintenance and replacement items on a CPAP machine. I am having trouble figuring out how to auto populate the next service date. The next service date is based on the specific item and the needed interval. I can get it to add X number of days to the entered current service date. But I can’t adjust the service interval based on the item selected. Trying to do IF “Filter” then interval = 14 and things like that. Only using the DATEADD function has worked for me but I can’t figure out how to make the # of add days a variable.
Not sure if this can all be done with calculations or needs scripting.
Simple case with fields and values is as follows:
Item: From pick list choose. Filter, Tubing.
Date Serviced: Enter date serviced.
Next Service Date: Auto calculate based on Item selected and service Interval.
Comments:Service intervals: Filter – 14 days and tubing 90 days.
An help and or recommendations would be greatly appreciated.
Thanks,
Tom-
This topic was modified 3 years, 6 months ago by
Tom Seputis.
May 13, 2023 at 7:56 PM #49416
BrendanKeymasterHi Tom,
You can do this with the
DATEADD()function and theIFEQUAL()function.For example:
DATEADD(Date;0;IFEQUAL(Service Interval; "Filter"; 14; IFEQUAL(Service Interval; "Tubing"; 90; 0)) ;0;2;0;0;0)the
IFEQUAL()function takes 4 parameters. A field, a value to compare the field with, a return value if the field equals the value, otherwise another value if they’re not equal.It does get a little complex when you’re embedding functions within other functions. It’ easier to understand scripting code though, so you could also do this using JavaScript.
Hope that helps!
May 16, 2023 at 6:58 PM #49429
Tom SeputisParticipantHi Brendan,
Thanks for setting me in the right direction. I came up with the calculation below for 2 of the items. It works so that based on selected item the next service date is given. I will need to finish up for the other components of the CPAP machine. I am also getting other ideas to use TapForms for other scheduled maintenance around the house.
DATEADD([Date];0;0;0;IFEQUAL([Item]; “Filter”; 14; IFEQUAL([Item]; “Tubing”; 90; 0)) ;0;0;0)
Thanks
Tom-
This reply was modified 3 years, 6 months ago by
Tom Seputis.
October 3, 2026 at 3:08 PM #54594
Tom SeputisParticipantHi Brendan,
I was working on this again and for some reason the formula I had above no longer works. (I am using iPhone Tap Forms 5.). I had the formula above working but then I removed it to add other items. I copied the original back into the formula field and then it stopped working. Field just remains blank instead of displaying next date.
Is there anything obviously wrong with this formula?
DATEADD([Date];0;0;0;
IFEQUAL([Item];“Filter”; 14;
IFEQUAL([Item];“Tubing”; 90;
IFEQUAL([Item];“Water Bath”; 180;
IFEQUAL([Item];“Nasal Cushion”; 14;
IFEQUAL([Item];“Nasal Mask Frame”; 90;
IFEQUAL([Item];“Head Strap”; 90;0))))));
0;0;0)Thanks
TomOctober 3, 2026 at 6:36 PM #54595
BrendanKeymasterHi Tom,
Make sure you’re using straight quotes and not curly quotes.
October 3, 2026 at 6:42 PM #54596
BrendanKeymasterIt also starts to get really complicated to diagnose when you have so much nesting going on within the expression. That’s when I switch to a Script field instead of a Calculation field.
October 3, 2026 at 7:22 PM #54597
Tom SeputisParticipantHi Brendan,
Thanks for the extremely quick response. The whole issue for this formula not working was the curly quotes. I was not aware of how subtle the difference is in the way that they look. Changed to straight quotes and now it all works fine.
I will have to learn more about scripting if I try anything more complicated than this.
Thanks Again,
TomOctober 4, 2026 at 9:25 AM #54606
BrendanKeymasterI’m glad the issue is resolved. Ya, curly quotes are a problem for the math parser. It only recognizes regular straight quotes.
-
This topic was modified 3 years, 6 months ago by
-
AuthorPosts
You must be logged in to reply to this topic.