Todd Posted July 29, 2003 Posted July 29, 2003 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
-Queue- Posted July 29, 2003 Posted July 29, 2003 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, "
Todd Posted July 29, 2003 Author Posted July 29, 2003 Outside of the field label, it is definitely empty. Does the name of the field affect this?
-Queue- Posted July 29, 2003 Posted July 29, 2003 The label has no effect on the contents of the field.
Dan-A Posted July 29, 2003 Posted July 29, 2003 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??
Todd Posted July 29, 2003 Author Posted July 29, 2003 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
-Queue- Posted July 29, 2003 Posted July 29, 2003 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("")].
Ugo DI LUCA Posted July 29, 2003 Posted July 29, 2003 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
Razumovsky Posted July 29, 2003 Posted July 29, 2003 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
Recommended Posts
This topic is 7791 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