January 10, 200620 yr Enter find mode type in tomorrow's date. 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
January 10, 200620 yr 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.
January 11, 200620 yr 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]?
January 11, 200620 yr 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:
January 11, 200620 yr 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 January 11, 200620 yr by Guest
January 11, 200620 yr 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.
January 11, 200620 yr 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.
January 31, 201115 yr 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...
January 31, 201115 yr 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