Required field data in layout in Filemaker Pro 10

I have a layout that is based on the Cataloging table.
One field from Cataloging is "required value" and you can't continue till it is filled in.
Another field (BldgCode) is from the related table Buildings. It is a "required value" in the Buildings table. But on the layout it can be left blank.
There is a field in the Cataloging table (BldgCode). If I make that field a "required value", wont all layouts based on the Cataloging table have to have the field properly filled in. Even if the field is not on the layout. I think I ran into something like this a couple of years ago.
Is there some way to require a field on a layout to be filled in regardless of its table's field's validation status?
Who is Participating?
Will LovingConnect With a Mentor PresidentCommented:
You may need to exert greater control over what you allow the end user to do. Use Custom Menus to remove the option to create a New Record using Control-N and then add a New Record button to your layout.

Alternately, and a bit more involved, you can use Custom Menus to create a duplicate of the of the Records menu and then modify the Menu to that "New Record" and Control-N, run a script that checks for completeness before creating a new record. It also gets a bit more complicated because you may not want to functionality on all layouts so you'll have to either assign the Records Custom menu to just that layout or make the attached new Record script take into account which layout it's being run from.
Will LovingPresidentCommented:
If I understand you correctly, you have a Buildings table with a BldgCode field which is a required field in this table, presumably because all buildings must have code, and possibly also because the BldgCode is being used as a Key field in relationships to other tables. The Cataloging table ALSO has a BldgCode field but it's not required for each record. However, on this layout, you want it to require that it be entered before the user can exit the record.

You are correct that if you set Cataloging::BldgCode to be a required field, it will be required for anywhere that the table appears. However, keep in mind that FileMaker's field validations only triggers when you attempt to leave a field or record. The problem with the built-in field validations is that they don't give you much control over when they fire or what messages appear.

There are a couple of ways to solve this:

1) If the layout is being accessed via a script, and the script is paused while the user enters data and then click's a Continue button to resume the script, then you can build a check for a value in the Cataloging::BldgCode field into the script using a Loop and Exit Loop If the field has a value in it. If you don't have a paused script but the user does have to click a button to continue to the next step, you can also build a check on the field into any script that navigates away from the layout. This used to be the only way to do this kind checking easily in FileMaker, but there are much better ways now, so read on...

2) Instead of having to run and pause and script, you can use a Script Trigger that fires when the user exits the record. Go into Layout mode for your layout and then Layouts menu > Layout Setup > Script Triggers tab.

There are a number of events that will trigger a specified script to run when that event occurs. I this case I'd probably use OnRecordCommit or OnLayoutExit. Create a small script (I like to preface Script Trigger scripts with "ST: " so that I can identify them easily) that check for a value in BldgCode and takes the user back to the field if they've left it blank. You can include other options if you want but that's the basic.

3) Another way around this is to use a Popover which gives you complete control over the entry. The user can click something that makes the popover appear with any required fields on it and then you use a script or script trigger to ensure that proper entries have been made.
maryj152Author Commented:
I think this will do what I need but,
When I use the script TSbldgCode onCommit

If [IsEmpty (Cat to Bldg::BldgCode)]
End If

I get the same result as when using  command(s) lines to GoTo Layout and/or Go To Field

The file is attached. It appears the first time when I try to leave the record with the field blank, but it also appears a second time after I have entered data into the field.
When I click yes the second time, I can leave the record without seeing the message a third time.
This will achieve the purpose but will be irritating to the users.
Any way to avoid the second pop-up? Is this because it relates to the table and not the layout?
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

Will LovingPresidentCommented:
This looks to me like you have set the validation on a field level rather than using a Script Trigger (or perhaps both). The clue being that field level validations will have the Revert Record button.

Turn off the field level validation and ONLY use the Script Trigger. The script should something like:

If [IsEmpty (Cat to Bldg::BldgCode)]
   Show Custom Dialog [ "A Building Code is required." ; "OK" ]
   Go to Field [ Cataloging::BldgCode  ]
End If
maryj152Author Commented:
That solved that problem. The clone I am testing on didn't match the live db in that area.
What happens now is The message pops up when I leave the record by clicking outside it.
If I click Record>New or Ctrl+N, the message pops up and a new blank record appears. Because there are two table validated fields in the record , when I click the ok for bldgCode the Date required messge appears over the new record.
Would one of the other On Event options take care of this?
maryj152Author Commented:
I will leave it as is for now. If the process is too irritating maybe it will break some bad habits.

I will look into custom menus later.

Thanks for the great help and information.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.