Substitute word for number in textbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Stang02GT
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    Substitute word for number in textbox

    I have a text box that displays a projects status, but the status is
    displayed as a number and the number means something like " Completed" or "In
    Development".

    Is there a way that i can have some VB code look and see that if there is an
    8, then display "Completed" or if there is a 10 it display "In development"?



    Visual Basic is going to be the end of me lol
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by Stang02GT
    I have a text box ... Is there a way that i can have some VB code look and see that if there is an 8, then display "Completed" or if there is a 10 it display "In development"?
    Substituting a string for a number is in itself quite simple, of course. But can you give us a bit more detail? For instance, what version of VB are you using? Is the textbox bound to anything? Is the value of the textbox of any significance to the program, or just a display for the user? Is it modifiable by the user, or locked?

    Comment

    • Stang02GT
      Recognized Expert Top Contributor
      • Jun 2007
      • 1206

      #3
      Originally posted by Killer42
      Substituting a string for a number is in itself quite simple, of course. But can you give us a bit more detail? For instance, what version of VB are you using? Is the textbox bound to anything? Is the value of the textbox of any significance to the program, or just a display for the user? Is it modifiable by the user, or locked?


      Yes not a problem at all

      I am running VB 6.3.

      The text box is bound to an ID field in a table( which is made by a make table query that pulls all information from a linked DB). The data in the table is either one of two statuses, Ready For Development or In Development. But my problem is that these statuses are identified by a number.

      8= Ready for Dev
      10= In dev

      On my form i have a status box and it is only showing a number id like it to show Ready for Dev. if there is an 8 in the box and In Dev if there is a 10 in the box.

      Comment

      • Taftheman
        New Member
        • Nov 2006
        • 93

        #4
        Originally posted by Stang02GT
        Yes not a problem at all

        I am running VB 6.3.

        The text box is bound to an ID field in a table( which is made by a make table query that pulls all information from a linked DB). The data in the table is either one of two statuses, Ready For Development or In Development. But my problem is that these statuses are identified by a number.

        8= Ready for Dev
        10= In dev

        On my form i have a status box and it is only showing a number id like it to show Ready for Dev. if there is an 8 in the box and In Dev if there is a 10 in the box.
        in your query add a case statement, this will work in sql server as SQL so i think it should work for access if you add it in the sql query.

        wher eyou have stated the selecting the Id in the query swap it with the following
        "Select Case When Id = 8 Then 'Ready for Dev' When id = 10 Then 'In Dev' End"
        then add the rest or ur select statement

        Comment

        • Taftheman
          New Member
          • Nov 2006
          • 93

          #5
          Originally posted by Taftheman
          in your query add a case statement, this will work in sql server as SQL so i think it should work for access if you add it in the sql query.

          wher eyou have stated the selecting the Id in the query swap it with the following
          "Select Case When Id = 8 Then 'Ready for Dev' When id = 10 Then 'In Dev' End"
          then add the rest or ur select statement
          Or ultimatly
          just case your result.

          Select Case (yourResult: should be a number in your case)
          Case is 10
          textbox.text1.t ext = 'In Dev'
          Case is 8
          textbox.text = 'Ready for Dev'
          End select

          in this case you do not want to assign the textbox to anything
          have a think about what you are trying to do if you still can't solve it,
          because there are many way such making the current textbox.visable = false and use this value in a case statement and populate a textbox that is visable

          Comment

          • Stang02GT
            Recognized Expert Top Contributor
            • Jun 2007
            • 1206

            #6
            Originally posted by Taftheman
            in your query add a case statement, this will work in sql server as SQL so i think it should work for access if you add it in the sql query.

            wher eyou have stated the selecting the Id in the query swap it with the following
            "Select Case When Id = 8 Then 'Ready for Dev' When id = 10 Then 'In Dev' End"
            then add the rest or ur select statement
            Unfortunately this form is running off of a table not a query.

            I created a query using Design view and then switched over to the SQL view, here is the code it gives me....

            Code:
            SELECT TRKALLIMSPROJECTS_TRKSCRSL.X5, TRKALLIMSPROJECTS_TRKSCRSL.X14, TRKALLIMSPROJECTS_TRKSCRST.Z1, TRKALLIMSPROJECTS_TRKSCRST.Z2, TRKALLIMSPROJECTS_TRKSCRST.Z3, TRKALLIMSPROJECTS_TRKSCRST.Z6
            FROM TRKALLIMSPROJECTS_TRKSCRSL INNER JOIN TRKALLIMSPROJECTS_TRKSCRST ON TRKALLIMSPROJECTS_TRKSCRSL.ID = TRKALLIMSPROJECTS_TRKSCRST.ID;
            X14 is the field with the status ID, where should i place your code?

            I tried it on my own but couldn't get it to work

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #7
              I've just used the query builder in Access to put together simple examples of using the IIF() and Choose() functions to decode a field. I just created a simple table with three fields called a (Text), b (Text) and c (Number). Here's the sample query...

              Code:
              SELECT Table1.a, Table1.b, 
                IIf([c]=8,"Ready for Dev","In Development") AS Converted,
                Choose([c],"","","","","","","","Ready for Dev","","In Development") AS Status
                FROM Table1;
              Here are the restults when I fed in some numbers...

              Code:
              [U]c	Converted          Status		[/U]
              1	In Development	
              4	In Development	
              8	Ready for Dev      Ready for Dev
              5	In Development	
              9	In Development	
              10	In Development     In Development
              4	In Development	
              8	Ready for Dev      Ready for Dev
              2	In Development

              Comment

              • Stang02GT
                Recognized Expert Top Contributor
                • Jun 2007
                • 1206

                #8
                I'm sorry guys but i can't get any of these to work....what about using the expression builder on the text box?

                Comment

                • Killer42
                  Recognized Expert Expert
                  • Oct 2006
                  • 8429

                  #9
                  Originally posted by Stang02GT
                  I'm sorry guys but i can't get any of these to work....what about using the expression builder on the text box?
                  I still think the Choose() function should do the trick.

                  Comment

                  • Stang02GT
                    Recognized Expert Top Contributor
                    • Jun 2007
                    • 1206

                    #10
                    Originally posted by Killer42
                    I still think the Choose() function should do the trick.


                    Ok where im having trouble is incorporating that into my statement in post #6

                    Comment

                    • Stang02GT
                      Recognized Expert Top Contributor
                      • Jun 2007
                      • 1206

                      #11
                      I'm still at a stand still on this....i walked away form the whole project this weekend just to clear my head and get away from it lol....

                      Comment

                      • Killer42
                        Recognized Expert Expert
                        • Oct 2006
                        • 8429

                        #12
                        Originally posted by Stang02GT
                        I'm still at a stand still on this....i walked away form the whole project this weekend just to clear my head and get away from it lol....
                        Sorry, I'll have to get back to this thread at lunch time (a few hours from now).

                        Comment

                        • Killer42
                          Recognized Expert Expert
                          • Oct 2006
                          • 8429

                          #13
                          Ok, for starters I have to say, I'm not too impressed with your field names. :( (The table names a far too similar, as well - very difficult to work with, in my opinion.)

                          I've chopped up the SQL a bit so I could follow it, but here's what I've come up with...
                          Code:
                          SELECT TRKALLIMSPROJECTS_TRKSCRSL.X5,
                                 TRKALLIMSPROJECTS_TRKSCRSL.X14,
                                 TRKALLIMSPROJECTS_TRKSCRST.Z1,
                                 TRKALLIMSPROJECTS_TRKSCRST.Z2,
                                 TRKALLIMSPROJECTS_TRKSCRST.Z3,
                                 TRKALLIMSPROJECTS_TRKSCRST.Z6,
                                 Choose([TRKALLIMSPROJECTS_TRKSCRSL.X14], "", "", "", "", "", "", "", "Ready for Dev", "", "In Development") As Status
                          
                          FROM
                          
                          TRKALLIMSPROJECTS_TRKSCRSL
                          INNER JOIN 
                          TRKALLIMSPROJECTS_TRKSCRST
                          
                          ON
                          
                          TRKALLIMSPROJECTS_TRKSCRSL.ID = TRKALLIMSPROJECTS_TRKSCRST.ID;
                          I don't know whether this will work or not - I've just tried to incorporate the Choose() function into your SQL. I'd recommend that for further help along these lines, you go to the Access forum. You will find a lot of SQL experience over there, while I'm kind of teaching myself as I go.

                          Comment

                          • Stang02GT
                            Recognized Expert Top Contributor
                            • Jun 2007
                            • 1206

                            #14
                            Those are not my field names. This is a linked table from another database, so those field names were not made by me. Trust me i know how hard it is to work with them.

                            Comment

                            • Stang02GT
                              Recognized Expert Top Contributor
                              • Jun 2007
                              • 1206

                              #15
                              Killer,

                              The code that you gave me worked great thank you !

                              Comment

                              Working...