|
-
Mar 3rd, 2004, 02:59 AM
#1
Thread Starter
Member
can i use select case in vba?
hi all~
i am currently doing a report using access97. i am quite new to vba so i am not sure if i am able to do this anot.
this is the situation:
I got a table with abbreviations. Eg. A = Apple, O = Orange. But I only keyed in A and O in my table. However in my report, i want my txtbox to display Apple instead of A when it was looped out into the txtbox.
my question is:
can i write a select case to generate out the words? if it is possible, how to use the code builder cause i notice the coding is a little different from the way i code using vb.
Thanks in advance~~
cheers,
stupidz
-
Mar 3rd, 2004, 03:01 AM
#2
Junior Member
short answer : yes
code builder does a lot of things differently but you can code the select case statement the same way you do in vb.
"much to learn you still have"
-
Mar 3rd, 2004, 03:16 AM
#3
Thread Starter
Member
Hi Shattered,
thanks for the fast reply!!!
hmm..
if it is in vb this is the way to code:
VB Code:
Select Case txtAbb.text
Case "A" : txtFullName.text = "Apple"
Case "O" : txtFullName.text = "Orange"
End Select
but i tried in vba, i.e i open up the code builder and try to code in it, the txtbox control does not has the .TEXT attribute and i was coding in the Detail_Format(Cancel As Integer, FormatCount As Integer) event.
did i code in the correct event? and how do i pass in a value into a textbox?
Thanks again~~
cheers,
stupidz
-
Mar 4th, 2004, 08:43 AM
#4
Junior Member
hmm...
Your code does actually work - just tried it myself. The code needs to be in the Change event though
VB Code:
Private Sub txtAbb_Change()
Select Case txtAbb.Text
Case "A": txtFullName.Text = "Apple"
Case "O": txtFullName.Text = "Orange"
End Select
End Sub
The text boxes do have a text property IF you are using vba objects, they don't if your using form objects.
If you got your text box from the FORMS toolbar then it won't have the text property.
If you got your text box from the CONTROL BOX toolbar then it will have the text property.
"much to learn you still have"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|