473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Substitute word for number in textbox

Stang02GT
1,208 Expert 1GB
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
Jul 25 '07 #1
17 1627
Killer42
8,435 Expert 8TB
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?
Jul 26 '07 #2
Stang02GT
1,208 Expert 1GB
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.
Jul 26 '07 #3
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
Jul 26 '07 #4
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.text = '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
Jul 26 '07 #5
Stang02GT
1,208 Expert 1GB
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....

Expand|Select|Wrap|Line Numbers
  1. SELECT TRKALLIMSPROJECTS_TRKSCRSL.X5, TRKALLIMSPROJECTS_TRKSCRSL.X14, TRKALLIMSPROJECTS_TRKSCRST.Z1, TRKALLIMSPROJECTS_TRKSCRST.Z2, TRKALLIMSPROJECTS_TRKSCRST.Z3, TRKALLIMSPROJECTS_TRKSCRST.Z6
  2. FROM TRKALLIMSPROJECTS_TRKSCRSL INNER JOIN TRKALLIMSPROJECTS_TRKSCRST ON TRKALLIMSPROJECTS_TRKSCRSL.ID = TRKALLIMSPROJECTS_TRKSCRST.ID;
  3.  
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
Jul 26 '07 #6
Killer42
8,435 Expert 8TB
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...

Expand|Select|Wrap|Line Numbers
  1. SELECT Table1.a, Table1.b, 
  2.   IIf([c]=8,"Ready for Dev","In Development") AS Converted,
  3.   Choose([c],"","","","","","","","Ready for Dev","","In Development") AS Status
  4.   FROM Table1;
Here are the restults when I fed in some numbers...

Expand|Select|Wrap|Line Numbers
  1. c    Converted          Status        
  2. 1    In Development    
  3. 4    In Development    
  4. 8    Ready for Dev      Ready for Dev
  5. 5    In Development    
  6. 9    In Development    
  7. 10    In Development     In Development
  8. 4    In Development    
  9. 8    Ready for Dev      Ready for Dev
  10. 2    In Development    
Jul 26 '07 #7
Stang02GT
1,208 Expert 1GB
I'm sorry guys but i can't get any of these to work....what about using the expression builder on the text box?
Jul 27 '07 #8
Killer42
8,435 Expert 8TB
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.
Jul 27 '07 #9
Stang02GT
1,208 Expert 1GB
I still think the Choose() function should do the trick.


Ok where im having trouble is incorporating that into my statement in post #6
Jul 27 '07 #10
Stang02GT
1,208 Expert 1GB
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....
Jul 30 '07 #11
Killer42
8,435 Expert 8TB
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).
Jul 30 '07 #12
Killer42
8,435 Expert 8TB
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...
Expand|Select|Wrap|Line Numbers
  1. SELECT TRKALLIMSPROJECTS_TRKSCRSL.X5,
  2.        TRKALLIMSPROJECTS_TRKSCRSL.X14,
  3.        TRKALLIMSPROJECTS_TRKSCRST.Z1,
  4.        TRKALLIMSPROJECTS_TRKSCRST.Z2,
  5.        TRKALLIMSPROJECTS_TRKSCRST.Z3,
  6.        TRKALLIMSPROJECTS_TRKSCRST.Z6,
  7.        Choose([TRKALLIMSPROJECTS_TRKSCRSL.X14], "", "", "", "", "", "", "", "Ready for Dev", "", "In Development") As Status
  8.  
  9. FROM
  10.  
  11. TRKALLIMSPROJECTS_TRKSCRSL
  12. INNER JOIN 
  13. TRKALLIMSPROJECTS_TRKSCRST
  14.  
  15. ON
  16.  
  17. 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.
Jul 31 '07 #13
Stang02GT
1,208 Expert 1GB
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.
Jul 31 '07 #14
Stang02GT
1,208 Expert 1GB
Killer,

The code that you gave me worked great thank you !
Jul 31 '07 #15
Killer42
8,435 Expert 8TB
The code that you gave me worked great thank you !
Hooray! A win for the VB forum. :)

I'm actually learning quite a bit about SQL just from attempting to answer these sort of questions.

Anyway, I'm glad we were able to help.

(Keep in mind, that's just one possible solution. It might be a good idea to go paste your current code into the Access forum and ask whether there's a better way.)
Jul 31 '07 #16
Stang02GT
1,208 Expert 1GB
Hooray! A win for the VB forum. :)

I'm actually learning quite a bit about SQL just from attempting to answer these sort of questions.

Anyway, I'm glad we were able to help.

(Keep in mind, that's just one possible solution. It might be a good idea to go paste your current code into the Access forum and ask whether there's a better way.)

Well good we are both learning something :) I am slowly but surely learning a great deal from this site thanks to people like you :)
Aug 1 '07 #17
Killer42
8,435 Expert 8TB
Well good we are both learning something :) I am slowly but surely learning a great deal from this site thanks to people like you :)
That's the great thing about a forum like this - it's a two-way affair. You also learn while answering questions, not just asking them.
Aug 1 '07 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Alex | last post by:
I need an Epic Editor substitute. I tried XML Spy and it does not meet my needs. I can't afford Epic Editor multi-user license at the moment and I need to render a proof-of-concept for a...
2
by: Phil Stanton | last post by:
Yes I know it can't be done in an editable form - well maybe not. Assuming I have a report textbox with CanShrink and CanGrow set to yes, is ther any way of calculating the length the textbox...
2
by: kelly.pearson | last post by:
I had some access 97 reports that I used to publish to MS Word that worked before we upgraded to Access 2K and Word 2K. Although there were some minor discrepancies, I was able to tweak the access...
4
by: Roger Zaugg | last post by:
I've got a question about C# together with MS Word 2003. I've got a C# applikation and I want to write any data into Word. But how I can position this text without linebreaks. I think it should...
0
southoz
by: southoz | last post by:
Good ay all , I'm fairly new to access(a little over 5 weeks now). Since I'v started I have picked up a lot of useful information from forums such as this and in doing so will share that information...
0
by: avi1000 | last post by:
Hi I want to do something with microsoft Word spell check and I wanted to know if it's possible. I have a TextBox and I want to check the word in the textbox with the help of Word spellcheck. I...
1
by: raghulvarma | last post by:
I have two textboxes one contains a set of words and the property of that textbox is set to multipleline and the other one is the place where the user will have to type the word to be searched. ...
1
by: sury | last post by:
I want to split a word into individual alphabets and substitute a word for each of the alphabets in c#. example: If the word entered is LATE, the output wud be L:London A :Apple T:Tom E:Egg
4
by: darith | last post by:
Hi all, I want to know code in vb.net to get number of selected text in MS Word. how can we write? Please help me. I need it urgent. in textbox we just write textbox.selectedtext so we can get...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.