wwyngaard Posted March 26, 2002 Posted March 26, 2002 I know this should be simple but I just can't get it to work. I want a number field to require a value if a text field has an entry in it. I have been trying to use IsEmpty but can't seem to get it right.
kyle Posted March 26, 2002 Posted March 26, 2002 hi, make a number field as a calculation field. if[isEmpty(text_field),1,0] or if[isEmpty(text_field),0,1] HTH KYLE [ March 26, 2002, 10:55 AM: Message edited by: kyle ]
Rigsby Posted March 26, 2002 Posted March 26, 2002 Lets give the two field names: Text field = TEXT Number field = NUMBER Ok, so the calculation for NUMBER is as follows: Case(Trim(TEXT )<> “”,0,1) This gives the result of 1 if the TEXT field is empty, otherwise 0. With the IsEmpty ( field ) command it would be so: IsEmpty ( TEXT ) This will return 1 if the TEXT field is empty, otherwise 0
Fitch Posted March 26, 2002 Posted March 26, 2002 The trick is getting the thing to actually VALIDATE. Kyle and Rigsby, try a little test and you'll see, it's trickier than it seems. Something like (not IsEmpty( )) seems an obvious answer, but it does not work as a validation, i.e., I can still enter data in the text field, and the number field can stay blank.
kyle Posted March 26, 2002 Posted March 26, 2002 quote: Originally posted by Fitch: I can still enter data in the text field, and the number field can stay blank. hi, fitch ! can you clear things up for me ? considering my calculation above , what you saying can happen ? if it can , how ? thanks, kyle
RussBaker Posted March 26, 2002 Posted March 26, 2002 For 2 fields in the file - "TEXT" and "NUMBER" The validation for the NUMBER field is: code: if(IsEmpty(NUMBER)=1,if(Length(TEXT)>0,0,1),1) When specifying the calculation for validation, you must un-check the "Validate only if field has been modified" box at the bottom of the window. This may have been the cause of non-validation issues in the previous posts. In the validation options, check the "Strict" and "Display custom message" boxes. Pick a message like - "Once text has been entered into the TEXT fields, you must enter a number in the NUMBER field". Now, if you type something into the TEXT field and the NUMBER field is empty, you will the get validation message. If you click OK - the only choice, then the cursor will be taken to the NUMBER field ready for you to enter the number. Russ Baker [ March 26, 2002, 03:19 PM: Message edited by: Russell Baker ]
Fitch Posted March 27, 2002 Posted March 27, 2002 Thanks, Mr. Baker, I had forgotten to un-check the "Validate only if field has been modified" box. Aha! Sorry everyone for my earlier density. FWIW here's my version of the formula: not IsEmpty (number) or IsEmpty (text) IOW, if either something is in the number field, or nothing is in the text field, all is well. No need to be explicit about the ones and zeros, unless you find that easier to read -- I don't, but I don't know if I'm in the majority on this.
RussBaker Posted March 27, 2002 Posted March 27, 2002 Fitch, As always, an elegant calc. No need for "Mr." in a friendly chat forum ?? Russ Baker
Recommended Posts
This topic is 8348 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