Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    3

    Unanswered: DBase (Xbase) expression

    I have 2 fields in a form called Status and Type

    If Status is = VERBAL AGR or WON then Type is = FORECAST
    If Status is = OPEN then Type should be = WORKING
    If Status is = ABANDONED then Type should be = CLOSED

    The code below works for VERBAL AGR and WON and OPEN
    What extra code do I need for testing the status ABANDONED ???????

    iif((Contsupp->Contsupref=="Won", .AND. (Contsupp->Contsupref=="Verbal Agreement"), "FORECAST", "WORKING"))

  2. #2
    Join Date
    Aug 2004
    Posts
    28

    Unhappy

    I am ghetting some mixed ideas about what you are trying to accomplish. It appears from the information in the first paragraph you are tyring to assign values to TYPE (btw, type is a reserved word in FoxPro. I would not reccomend using it as a variable or field name as it can POSSIBLY cause problems later on.) based on the current value of STATUS (another reserved word.)

    My reccommendation would be to NOT use the IIF() function as it is designed for a comparrison of 2 values (although you can add more depending on which version of FoxPro you are using but it gets to be very difficult to read).

    What I would do instead would be to use the DO CASE statement as follows:

    DO CASE

    CASE STATUS = "VERBAL AGR" OR Status = "WON"
    TYPE = "FORECAST"

    CASE STATUS = "OPEN"
    TYPE = "WORKING"

    CASE STATUS = "ABANDONED"
    TYPE = "CLOSED"

    ENDCASE

    Also, to make it a little better (to catch possible case sensitive issues and padded spaces) I would add the ALLTRIM() and UPPER() functions to the STATUS Field. for example: CASE ALLTRIM(UPPER(Status)) = "WORKING"


    I hope this helps.

    AmcAmx

  3. #3
    Join Date
    Nov 2004
    Posts
    39
    AmcAmx is right!
    But if you really want to use Immediate If (IIF) for some reason,
    here is what you need:

    iif((Contsupp->Contsupref=="WON" .OR.
    Contsupp->Contsupref=="VERBAL AGR"), "FORECAST",
    iif(Contsupp->Contsupref=="OPEN", "WORKING", "CLOSE"))

    NOTE:
    -I used .OR. (according to your requirement) not .AND.

    -Any value of Contsupp->Contsupref other than the tested values
    will return "CLOSE"
    You can trap this by adding additional IIF and
    check if the value is "ABANDONED"
    Last edited by RedAxl; 11-30-04 at 21:31.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •