Jump to content

Before Printing Check Fields for Value

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

Recommended Posts

Hi Everyone...Is there a way (Script) to check some fields for a value before going to a report...

I would love a script to pop up a message with what fields I need to fill out for a report. Just a making sure a value is in each required field for a report...and a message that says which need to be filled out...or make the fields turn a color if not field is in them for a report.?


FileMaker Version: 6

Platform: Windows 2000

Link to comment
Share on other sites

Just have the script validate by checking the fields using the If and Else script steps. You can either use Show Message, or you can get fancier with Show Custom Dialog. So for example:

If ["IsEmpty(payment)"]

Show Message ["The payment field must be entered before printing."]


Print []

End If

Is this the idea you were searching for?

Link to comment
Share on other sites

You posted what you want - but not why. I would think you are concerned that you will lose the consistency and integrity of your reporting process. If you produce a complex monthly report (which you are beginning to count on), you or your Users can not afford to forget one silly (critical) little field such as Type = Sales. crazy.gif Bummer. Because when you do, you may not notice it until 'too late' and you may have conducted your business based upon misinformation or (at the least) wasted time. So reporting errors are potentially harmful as well.

You need tight scripting (so your report results are consistent) on an individual report basis. And it must also be forgiving - allow User error and provide exits. I call it Idiot-proofing.

Other tools in our arsenal (in addition to Sam's great ideas about Show Message and Show Custom Dialog) are special layouts and global fields. The idea is to create one script for each report. These Report scripts can share sub-scripts but each 'type' of report will have its own requirements. And it usually will use many methods in combination to navigate, find, validate and even print. List your process before you choose your weapons. And then script it. To answer your question, you can test that a field has been filled in (for searching) by using a global field to hold the data. Then a script step If [isEmpty(global)] could be used.

Apologies for getting a bit off-subject. I wanted to point out that you are indeed on the right path. Script it well ... and you will always be able to depend on that report. If you want to give us a specific Report example, we'll help you with specific validation/navigation ideas! wink.gif

Link to comment
Share on other sites

I would love a script to pop up a message with what fields I need to fill out for a report... can I make it not print if there is something missing and print when all fields are there?

I would show them which fields should be filled in and then after they did, I would test and make sure they did. Sam gave you an example of testing that a field is not empty. You need a good script, and there are hundreds of ideas on Forum of scripted finds. But here is a 'generic' idea for you, hopefully to get you going in the right direction ...

Place your required fields (and possibly optional ones?) on a layout called FIND. Don't place your real fields but instead use globals. Put text at the top of the layout with "Enter something in every field then click the Find button." This layout will tell them what fields are required. This script (attached to the FIND button) will make sure all fields are filled in. It would look something like:

Set Error Capture [On] stops FM dialog box if no records found

Allow User Abort [Off] keep someone from [Esc] and ruining your script

If [ (IsEmpty(global1) or IsEmpty(global2)) or...] test if fields were left empty.

Show Message [Try Again, Cancel; "Enter something in every field."]

If [ Status(CurrentMessageChoice) = 2 ] User selected Cancel

Set Field [global1, ""] blank globals for the next person

Set Field [global2, ""]

Go to Layout [original layout] Take them back to where they started

End If

Halt Script Selecting 'Try Again' stops on FIND layout and leaves globals intact so person can just correct what they had started smile.gif

End If

Enter Find Mode [ ] sets your report fields with User's 'fake field' entries (the globals)

Set Field [RealField1, global1]

Set Field [RealField2, global2]

Perform Find [Replace Found Set]

If [ not Status(CurrentFoundCount) ] No records matched criteria entered in the globals

Show Message [Yes, No; "No records found. Try again?"]

If [ Status(CurrentMessageChoice) = 2 ] User selected No

Set Field [global1, ""] blank them for the next person

Set Field [global2, ""]

Go to Layout [original layout] Back to where they started again

Show All Records

End If

Halt Script 'Yes' - we again give person another chance to do it right. End If

Go to Layout [Report Layout] and possibly Enter Preview Mode

Print [ YAY!!]

Apologies that script isn't properly indented. It is much easier to read when it is. crazy.gif

As I said, it would depend upon the complexity of your report and search needs and that is why we have been hesitant to give specifics. Usually one would also script for invalid entries as well. But I hope the logic of it is more clear. You haven't told us very much or even provided an example of what you need, so I remain unsure whether I'm helping or way off target. wink.gif

Link to comment
Share on other sites

  • 2 weeks later...

wow..thanks for the great response...I will keep trying to learn this... I really do thank you...My data base is getting a little better...But I think I might need somesome who really knows how to build one...and tweek it completely...I have way to many layouts...when I am sure There is a better way to do it... I will Keep intouch smile.gif

Link to comment
Share on other sites

This topic is 6471 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.