Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Thanks!

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

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.

  • Author

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]?

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:

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

  • Author

Thanks a bunch LaRetta!

  • Author

And thanks John!

  • Author

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.

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

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...

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

Try Get(CurrentDate)

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.