4 Replies Latest reply on Jan 17, 2011 1:50 PM by philmodjunk

    Auto-Enter "N/A" in Empty Fields

    bt22true

      Title

      Auto-Enter "N/A" in Empty Fields & Count Fields without "N/A" Entered

      Post

      Hello,

      I'd like to be able to create a script that on finishing data entry and creating a new record, will automatically enter the text "N/A" in any field that is empty. How can I go about doing this in a way that doesn't require that I do a massive If calculation?

      Also, once I have that set up, I'd like to have a field automatically count how many fields do not have "N/A" written in them. Is there a way to do this?

        • 1. Re: Auto-Enter "N/A" in Empty Fields & Count Fields without "N/A" Entered
          philmodjunk

          You could set an auto-enter field option to enter N/A into all such fields when the record is created.

          To count the N/A fields within a single record, this calculation would work:

          (Field1 = "N/A") + (Field2 = "N/A") + (Field3 = "N/A") ...

          • 2. Re: Auto-Enter "N/A" in Empty Fields & Count Fields without "N/A" Entered
            bt22true

            I'd like the "N/A" to be entered into fields once I've finished data entry, and want to move on to the next record (effectively when I want to save the record). I don't really want to have to delete "N/A" in every box that hasn't been changed yet.

            • 3. Re: Auto-Enter "N/A" in Empty Fields & Count Fields without "N/A" Entered
              philmodjunk

              Ok, wanted you to consider that though, as it's much easier to set up. You can format the fields to select field contents on entry which can make deleting the N/A's easier. A script trigger that kicks in on field entry could also delete the field contents if they are "N/A" and an OnObjectExit trigger could put the "N/A" back upon exit if the field is empty.

              Only other approach I can think of is to write a script that checks each of these fields in turn and enters "N/A" if they are empty. The OnRecordCommit layout trigger can be used to perform this script.

              • 4. Re: Auto-Enter "N/A" in Empty Fields & Count Fields without "N/A" Entered
                philmodjunk

                My last post kept nagging at me. I kept thinking there had to be a better way and this is an idea that finally percolated to the top of my brain...

                Define a number field, Switch

                Use this auto-enter calculation on each field where you wan "N/A" entered if the user does not enter a value:

                If ( switch and isEmpty ( self ) ; "N/A" ; self )

                Clear the "do not replace existing value" option.

                Write a script:

                Set Field [YourTable::Switch ; Get ( ScriptParameter ) ]

                Set up the OnRecordLoad and OnRecordCommit triggers to perfom this script. Pass True as the parameter for OnRecordCommit and False as the script parameter for OnRecordLoad.

                This switch field acts as a triggering field to make sure that N/A is entered into a record only after the user has had the opportunity to enter a value first.