Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

What is the code to search all records for tomorrow's date?


This topic is 5047 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Enter find mode

type in tomorrow's date. :B

or,

use the Insert Calculated result script step in a script and attached to a button.

Go to Layout [ original layout ]

Enter Find Mode

Insert Calculated Result [ YourDateField, Status(CurrentDate) + 1 ] [ Select entire contents ]

Perform Find [ Replace Found Set ]

Lee

Posted

Note that Insert Calculated Result must be on the layout in which you fire the script. Set Field[] is the preferred method here.

Be sure to include the appropriate protections in that script, such as starting with Set Error Capture[On]and Allow User Abort [Off]. And use Get(CurrentDate) instead of Status(CurrentDate) for vs. 7/8.

Posted

Thanks to both of you. LaRetta can you please post the entire code like Lee did with your suggested substitutions? I don't know much about coding so if I could do a copy and paste that would be great! Thanks. Also, what is Set Error Capture [on] and Allow User Abort [off]?

Posted

Hi Rydog,

Allow User Abort[Off] will protect your script from User hitting [ESC] and terminating it prematurely. I always include this step at the beginning of my scripts. Set Error Capture[On] is used prior to certain script-steps such as Find[] to suppress FileMaker's own dialog box, ie, if records not found then FM will attempt to control it by providing prompt with CANCEL or CONTINUE. But you should control what happens at this point, not FM. Here is a generic script which might fit your needs:

Allow User Abort [ Off ]

Set Error Capture [ On ]

Go To Layout [ your layout to display your found set ]

Enter Find Mode [ ]

Set Field [ yourDateField ; [color:red]Get ( CurrentDate ) + 1 ]

Perform Find [ ]

If [ not Get ( FoundCount ) ]

Show Custom Dialog [ "No Records Found " ] ... just have OK as default button ...

Show All Records

Go To Layout [ original layout ]

Halt Script

End If

... now you have your found set and you can add additional lines to sort, print or whatever you wish.

Note: Only the portion in red should be placed within the calculation dialog on the Set Field[] script-step.

LaRetta :wink2:

Posted (edited)

All you really need to do is replace the Insert Calculated Result function with the set field function. Also LaRetta mentioned that you should add Error capture and to turn off abort by user.

You can use a popup dialog box if an error occurs.


Set Error Capture [On]

Allow User Abort [Off]

Go to Layout [ original layout ] 

Enter Find Mode 

Set Field [ YourDateField; Get(CurrentDate) + 1 ]

Perform Find [ ]

If [Get ( LastError ) = 400 ]

Show Custom Dialog ["Error"; "Your search criteria is empty"]

Else If [ Get ( LastError ) = 401 ]

Show Custom Dialog ["Error"; "Tehre are no matching records"]

End If

Update: She beat me to it. :B

Edited by Guest
Posted

John,

What is the purpose of this code?

f [Get ( LastError ) = 400 ]

Show Custom Dialog ["Error"; "Your search criteria is empty"]

Else If [ Get ( LastError ) = 401 ]

Show Custom Dialog ["Error"; "Tehre are no matching records"]

Also, can I just copy your entire code and paste it in the button script and have it work on the fly? Thanks.

Posted

Well those are actions to take if there are Error Codes that are captured when you Set Error Capture on. If you go to the help section of FileMaker and do a search for 'Error' you will see the whole list of codes. 400 is Find criteria empty and 401 is for No records match the request.

I used Error codes, Laretta used another method for returing a message when no records were found.

Laretta wrote:

If [ not Get ( FoundCount ) ]

Show Custom Dialog [ "No Records Found " ] ... just have OK as default button ... 

Show All Records

Go To Layout [ original layout ]

Halt Script

End If

You should always write your scripts to compensate for user error.

  • 5 years later...
  • Newbies
Posted

Correct me if I'm wrong, but Filemaker Pro 10 Advanced doesn't seem to have the Status(CurrentDate) function...

Then again - I'm a newby to FM, so could just be doing it wrong...

Posted

All of the Status functions were changed to Get wih the relese of v7

Try Get(CurrentDate)

This topic is 5047 days old. Please don't post here. Open a new topic instead.

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.