1. Making sure data is filled in is usually done by field validation ("Not Empty") rather than by script.
2. step 4 of your script is that if the field is empty (a bad thing) you go to a different layout...why would you do this?
3. Your custom dialog asks for DOB only if there already is one...it is on the other side of the "else".
4. If DOB is empty, you set a variable to a value that includes the emptiness...what would that accomplish?
5. you set the variable...then do nothing with it. Why are you trapping the words and the emptiness? What are you trying to accomplish?
I would recommend that you handle this through field validation (In field properties dilaog box).
I am not using field validation as it prompts you then every time you go in another field or section of the layout if it is blank. I am going to put this script on the layout exit once I get it to work properly. It will allow me to check multiple fields without getting prompted every single click around the layout as happens with field validation.
Step 4 is if the variable is empty not a field, which I want it to be...so dont see that as a bad thing. Basically if the DOB field is empty it sets the variable $NoData to have text in it. then later steps look and see if there ended up being text in the variable and shows custom dialog to fill in the empty field, if the field wasn't empty, no text gets pasted into that variable, which then allows you to go to the layout. That's the idea anyway.
I've sorted it, i needed to move the end if up after the first if.....works like a charm now.
I'd write such a script like this:
If [Isempty ( Table::Field1 ) ]
Show Custom Dialog [ "Field 1 is missing a required value" }
If [ IsEmpty ( Table::field2 ) ]
Show Custom dialog
Go to layout ["main...
That makes it very easy to add/remove change your validation tests on each field.
Thanks Phil, I suppose there is multiple ways to do it alright, here is what I ended up with, it then gives me one nice little dialog box with a list of the empty fields in the one dialog box.....