New Record with prefilled date field
What would be the code to put in "on Create" so that when the new record is created, the Date field is automatically completed with the next date of the previous.
Example.
one record is set on the 1st January. I press a button which creates a new record. The new record will automatically have the 2nd January
is this possilbe?
10 replies
-
let d := last((select YourTable).Date); Date := if d then d + 1 else today() end
Steven
-
Thanks for the reply Steven.
Just double checking.
Ive inputted the code into my table and no errors are coming up, but nothing seems to have changed.
Ive put the code in my button and ive got it so on click. It creates and opens a new record. But the date field still stays empty.
the code on the button is :
let newRec := (create 'Sight See Fish Feed / Marine Discovery Cruise Booking Sheet');
openRecord(newRec);let d := last((select 'Sight See Fish Feed / Marine Discovery Cruise Booking Sheet').Date);
Date := if d then d + 1 else today() endIs this correct or should i have the code in another field?
thankyou very much for your help
-
Thank you steven for the clear up.
Ive inputed your code, and it seems to be working. However, it is creating every alternate day. As in its the i created a record for the 19th, i click the button and it creates the next record with the 20th which is great. I then click the button on the new record and it creates a new record with the 22nd as the date.
-
Ignore last reply, Ive inputted your original code into the trigger on new record and it works and treat.
Thankyou very much for your assisstants
Content aside
- 2 yrs agoLast active
- 10Replies
- 240Views
-
2
Following