Steve T Cunliffes Posted March 20, 2014 Posted March 20, 2014 Hi, Hoping somebody can explain why this happens. If you have a basic script attached to a button as follows: - If [IsEmpty (Projects::Client Name )] or If [Projects::Client Name = "")] f you place the cursor in a field and hit return then click out the field, so field is still free of any text but has a return in it, the script fails. If I go back into the field and take the return out, the script works. It's as if the return is acting as an entry even though the field is still blank/free of any text/data....... confused I came across when asking a colleague to test a layout and he must have hit return to exit the field after entering txt. We then go back and remove the txt (not realising at first there was a return in there) and to my surprise the script failed and the layout exited. Steve
Lee Smith Posted March 20, 2014 Posted March 20, 2014 (edited) Any character in the field makes the field act as if there is text in it. i.e. a space, return, etc. In other words, the FIELD is NOT empty. What kind of data is suppose to be in the field? Can you isolate the records some how into a Found Set? If so, you could do a Replace of returns, but it will effect all of the records in the Found Set, so it is important to be sure that only the records you want to do this with are in the Found Set. It is not something you can UNDO and should be done on a copy. HTH LEE Edited March 20, 2014 by Lee Smith added additional info
Steve T Cunliffes Posted March 20, 2014 Author Posted March 20, 2014 Hi Lee, It's just simple txt and numbers that are supposed to be in the fields i.e. an address, persons name, tel no. etc. I'm not familiar with Found Set but will read up on it as I have a good few books here i've purchased to help me with my learning of FM. Steve
Lee Smith Posted March 20, 2014 Posted March 20, 2014 I’m unclear as to weather or not these records have any valued data in them. I’m sorry if I wasn’t clear. Here is a thought. Try using a Table View and sort a column that this happened in, the records should appear on the Table at the top (I think), and you can delete them. FYI, a found set is created when you do a search. The result can be any number of records from 0 to All that meet the search criteria.
Steve T Cunliffes Posted March 20, 2014 Author Posted March 20, 2014 Hi Lee, Ah right yes, I understand what you mean now by a found set. I don't think this is what i'm after however and don't think I have explained my problem properly. It's not that I have lots of records where this has occurred i.e a return or space but no data and need to easily find and delete them. Also the database isn't live yet, i'm only testing it so losing any data at this stage wouldn't be too critical anyway. My layout has several fields that the user will 'fill in' then submit the form. They are however able to go back into that particular record/form and edit the data in the fields. What if when editing a field they: - remove the original entry (leaving a blank field), Then accidentally hit the space bar or return key and move onto the next field Get distracted, forget to fill in the blank field and hit the submit button. The form will submit as as you kindly pointed out above, the space or return are acting as characters. I know this must sound silly to an FM Expert, but it's a scenario that actually happened and so could happen again. I can't think of any scenario where an empty field wouldn't act as an empty field unless it had 'actual' data in it. Before resorting to the forum, I spent hours reading through my books to find a script that basically worked by doing just that, i.e. looking for actual physical txt or numbers else returned that the field was empty. I hope I have explained myself and my problem a little clearer to you. Steve
Lee Smith Posted March 21, 2014 Posted March 21, 2014 Maybe you could set the keys that may be used to exit the field FileMaker Help page
LaRetta Posted March 21, 2014 Posted March 21, 2014 (edited) I can't think of any scenario where an empty field wouldn't act as an empty field unless it had 'actual' data in it. Hi Steve, But it DOES have data in it and that is pretty standard in many programs. And yes, a User can hit return three times even when it should be two, for separating a paragraph. And they can type //////// all they want. They are responsible for their text and validating it would be difficult. But we understand what you mean and to add to Lee's suggestion, this might work for you, attaching this as trigger OnObjectExit: If [ not WordCount ( table::Field ) and Code ( table::Field ) ] Set Field [ table::Field ; "" ] End If Carriage returns, spaces, dashes (and all word separators) would be stripped if no words existed. You may wish to provide them a message or not depending upon the User process. And if this is CRITICAL, handle it through Privileges as well. I cannot think of a normal situation where this might fail but keep in mind that if the field only contains dollar sign it will be removed. Same with # and all word separators ... but only if they are all that exists in the field. So a field with ########## ... would be cleared. ADDED: This could be set up as an auto-enter (REPLACE) as well. In fact, that would be better so you are free to use OnObjectExit trigger on that field in the future if you wish. Actually this should do it ------> Auto-Enter (REPLACE) with: Case ( WordCount ( Self ) ; Self ) Edited March 21, 2014 by LaRetta
Lee Smith Posted March 21, 2014 Posted March 21, 2014 Here is a different take. There is a Custom Function by Ray Calogon called Trim4 that I added to the field Trim4 ( TextFormatRemove ( Self ) ). Change the Data Entry to allow the Return for entry and you should be good to go. I made up sample file for you too. Steve.fmp12.zip
Steve T Cunliffes Posted March 21, 2014 Author Posted March 21, 2014 LOL you folks are amaizing, both work brilliant! Thank you once again for taking the time to reply and help me, it's very much appreciated. Steve
Recommended Posts
This topic is 3899 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 accountSign in
Already have an account? Sign in here.
Sign In Now