Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2004
    Posts
    361

    Unanswered: if then statement

    If a value on a table is in numeric form, is there a way to query that number into and an if then statement that will chanage it into a word.

    Example:

    if the number 123 = dog then how would you convert that 123 number into the word dog?

    Any help is appreciated.

  2. #2
    Join Date
    Jun 2002
    Location
    Houston, TX
    Posts
    116
    If you are literally wanting to change a number into a specific letter would probably require some VBA. Like in your example where 1=D and 2=O and 3=G.

    But if you simply want to change a numeric into a character use:
    Char(fieldname)

    You would do this in a query.


    HTH
    texasalynn

  3. #3
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    What rule dictates the character equivilent of the number? do you have another table where you can lookup 123 and find "dog"? Or is there only a few comparisons you need to make? If it's the first option, then you need to get the value through sql. Otherwise you can use an immediate if:

    IIF(yourField = 123, "dog", IIF(yourField = 345, "cat", "default string"))

    This would return "dog" for 123, "cat" for 345 and "default string" for any other number. You can nest as many IIF() statements together as you like.

  4. #4
    Join Date
    Mar 2004
    Posts
    361
    when would i type the if statement. Would it be at the property level of that field or would it be in VBA?

  5. #5
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Originally posted by tjarvas
    when would i type the if statement. Would it be at the property level of that field or would it be in VBA?
    You could apply that to either the datasource for the report/form, or you can apply it to the individual field on the form/report level.

  6. #6
    Join Date
    Mar 2004
    Posts
    361
    How do you apply it to the field level on the form? Is there a property that I would change?

Posting Permissions

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