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

    Unanswered: Need help to convet data in a word

    Here is my problem. I have a table that i query with a unique identifier. This identifier finds a record that lists 2 possible results 545 or 345. If the identifier returns 345 I need to convert that number into a word but if it returns 545 I can leave it as a number. I assume that I will have to write and if then statement but I don't know where and what to write. If anyone has any ideas or neeeds any clarification please let me know.

  2. #2
    Join Date
    Feb 2004
    Location
    Washington
    Posts
    49
    update table_name
    set field_name = word to convert
    where id = 345

    this will update every record in the table that has the value of 345 in the id fields (which by the way, shouldn't EVER happen if it is a primary key)
    Cathy

  3. #3
    Join Date
    Mar 2004
    Posts
    361
    That is kinda close. Let me try this again. On my form I search the table with a unique number. This number returns a lot of information off of that table. if the search returns 345 then I want it displayed as a word. I can't change the data in the table because that is updated everyday with a numeric number. Maybe that is a little more clear.

    Thanks

  4. #4
    Join Date
    Feb 2004
    Location
    Washington
    Posts
    49
    There are many ways to do this (as is the case with all programming) and how you do it depends on how you are developing your application. The simplest thing to try is to have an unbound field that evaluates the data and acts upon it. I'm not sure this is exactly what you want, but this should you give you a start and you can play around till you get it how you want it:

    In the unbound field control source, create an expression similar to

    if [id] = 345 then "What your text should be" else [id]
    Cathy

  5. #5
    Join Date
    Mar 2004
    Posts
    361
    I typed if [Type] = "345" then "Dog" else [Type] and it gave me an error.

    what this sould accomplish is, if 345 is returned in the query then Dog should be displayed in the unbound text box, correct?

  6. #6
    Join Date
    Feb 2004
    Location
    Washington
    Posts
    49
    What is the error? Is [Type] a field in your recordsource?
    Cathy

  7. #7
    Join Date
    Mar 2004
    Posts
    361
    Type is the control source. That is also the name of the column on the table that I am querying.

  8. #8
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    First, rename the textbox that you are using. When you look at the Properties for the textbox it is in the Other tab. It is probably 'Type'. Change it to 'txtType'. Then, as the ControlSource put in:

    =IIf([Type]=345,"YourWordHere",[Type])

    This is an Immediate If statement and there are three parts to it. The first part is the condition ([Type]=345), the second is what you will get if it is true ("YourWordHere"), and the third is what you get when the condition is false ([Type]).

    This is considered a calulated field and it is only for display purposes. Do you need to modify it and have it saved in the table?

    The renaming is important, if you don't rename the textbox then you will get an error.

  9. #9
    Join Date
    Mar 2004
    Posts
    361
    That worked for the most part. I got the correct word to show in the text box but when I merged that data with word the number showed up on the word document instead of the new word. Any clues?

Posting Permissions

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