Jump to content
Server Maintenance This Week. ×

Open to record with todays date.


Recommended Posts

In my file, I have a date field, with one record for each date, going out for the next 60 days.  There's a script that creates new records once the last one is less than 60 days old, but the existing records go back for one year.  I also added a field called todays date, and when the file is opened, the current date gets entered there, and yes, it's a global field.

What I want to do is when I open FM, have it go to the record where todays date is the same as the date field.  In my opening script, there is the option to go to the record based on a calculation, but nothing seems to work.  I added another calculation field that if the date is the same as todays date, then it gets that record number, otherwise it's a zero, though I did change it to be an empty field.  And that field is getting the correct record number on the correct field, and as I understand it, that should then tell FM to go to that record number.  But it's always opening to the first record.

Link to comment
Share on other sites

47 minutes ago, Tpaairman said:

have it go to the record where todays date is the same as the date field.

There are a number of ways you could accomplish this. Which is best for you depends on what else you want to happen - for example, what other records you want to have in your found set. And also, how much resources you want to expend on this.

The simplest way is of course to find the record. All you need for this is a script (or a single-step button).

Another option is to start by showing all records, then calculate which record to go to by subtracting today's date from the date of the very first record (which could be hard-coded in the script, or retrieved from the first record every time the script is run). Again, no other resources other than the script are required for this.

Yet another way would be to define a relationship matching an unstored calculation field returning the current date to the date field, and use Go to Related Record script step to get there. (There is more to discuss here regarding the surrounding found set.)


As for your attempt: IIUC, your calculation field returns the wanted number only "if the date is the same as todays date" - so you have access to that number only if you happen to already be on that record.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.