July 29, 200322 yr I'm trying to use the IF function to trigger one of two scripts. Currently, I have: IF [isEmpty(Field 1)] Perform Script [script 2] ELSE Perform Script [script 3] End If Scripts 2 and 3 work fine when I trigger them independent of the IF function, so I know that it's a simple case of my IF script not working. Basically, I want it to look at Field 1, and if that is Empty, trigger script 2. If field 1 is not empty, it should trigger script 3. Help, please! Todd
July 29, 200322 yr Is there by chance any spaces or carriage returns in Field 1? If so, it isn't empty. For text fields, I would use IsEmpty( Substitute( Substitute( Field 1, "
July 29, 200322 yr Author Outside of the field label, it is definitely empty. Does the name of the field affect this?
July 29, 200322 yr Hi Todd, Have you tried your IF with another field? or with the Trim function? BTW is your test field a text field?? does it have a default value set-up in field defenitions? You are certain your field is empty because script-3 is always the one that runs??
July 29, 200322 yr Author To sum up all of the questions: Behavior: The IF script appears to check the field, but it never triggers the 2nd or 3rd script. Mode: In Layout Mode or Browse Mode, same thing occurs I tried flipping the IF script, in that I tried to use the IfValid function to trigger (and flip-flopped the scripts being triggered), but that didn't work either. I know the field is empty because I use the Clear function to clear it shortly before this script runs. It is a number field, by the way - perhaps that has some bearing on the matter? I'm not familiar with the Trim function - what is that? I'll check the field definitions - maybe I inadvertently added something I shouldn't have. Thanks
July 29, 200322 yr Aha. Don't use Clear() unless the field is on the current layout. It won't work. It's safer to always use SetField[field, ""] or, in the case of dates, SetField[field, TextToDate("")].
July 29, 200322 yr I know the field is empty because I use the Clear function to clear it shortly before this script runs. Wether you use Clear or SetField....Why run an If script then
July 29, 200322 yr Hmmm- sounds like we need more info. considering it is a number field, try: IF [field1>0 Perform Script [script 3] ELSE Perform Script [script 2] End If if that doesnt work, try: IF [field1>0 show message "Field1 is > 0!" ELSE show message "Field1 is not > 0!" End If if you get no results with the first one and a dialog box with the second, your problems lie in your scripts 2 and 3. If you get no dialog box with the second, something very odd it happening (are you sure field1 exists? are you sure you are triggering the correct script?) Also- what are scripts 2 and 3 doing? try putting pauses at the beginning of scripts 2 and 3. If your scripts 2 and 3 are taking you to a layout in a different file, it may be thaat everything is working fine, but just returning to first file to finish the first script. -Raz
Create an account or sign in to comment