Options Click: Display Free Text in Text Box

jwood29

Registered User.
Local time
Today, 06:12
Joined
May 13, 2008
Messages
28
I am trying to use an option group that has radio buttons 1-10, that when clicked it will display free text into another text box that I have.

1 and 2 would say: Needs Improvement
3, 4, 5 would say: Satisfactory
6,7,8 would say: Above Average
9 and 10: Superior.

What would the code for this look like?

Thanks in advance all.

JWood29
 
Look at Select/Case in VBA help, put the code in the after update event of the frame and the code would look like:

Me.TextBoxName = "Needs Improvement"
 
thanks pbaldy. I did the above and got it to display "Needs Improvement".
But this only works for when I click radio button 1 in the group. How would I also have it say "Satisfactory" when a 3, 4, or 5 is chosen.

Thanks.
 
Did you look at the Select/Case structure in VBA Help? That would let you test for the value and put the appropriate value in the textbox.
 
I did look at the select case help in vba help, but am a bit confused.

here is the code I have so far and it does not display anything.


Private Sub score_opt_AfterUpdate()
Select Case Score
Case 1, 2 'Needs Improvement'
Case 3 To 5 'Satisfactory'
Case 6 To 8 'Above Average'
Case 9, 10 'Superior'
End Select
End Sub


Thanks for your help. Much appreciated.
 
Code:
Private Sub score_opt_AfterUpdate()
   Select Case Me.score_opt
      Case 1, 2
           Me.YourTextBoxName = "Needs Improvement"
      Case 3 To 5 
           Me.YourTextBoxName = "Satisfactory"
      Case 6 To 8 
           Me.YourTextBoxName = "Above Average"
      Case 9, 10 
           Me.YourTextBoxName = "Superior"
   End Select
End Sub
 
It doesn't know what "score" is, so you want to refer to the frame:

Code:
  Select Case Me.score_opt
    Case 1, 2    'Needs Improvement'
      Me.TextBox = "Needs Improvement"
    Case 3 To 5    'Satisfactory'
      Me.TextBox = "Satisfactory"
    Case 6 To 8    'Above Average'
    Case 9, 10    'Superior'
  End Select
 
Awesome: Got it to work guys. Boblarson nailed it. Thanks both of you for helping me get this working... Good Day.

Final working Code:

Private Sub score_opt_AfterUpdate()
Select Case score_opt
Case 1, 2
Me.score_txt = "Needs Improvement"
Case 3 To 5
Me.score_txt = "Satisfactory"
Case 6 To 8
Me.score_txt = "Above Average"
Case 9, 10
Me.score_txt = "Superior"
End Select
End Sub

jwood29
 
Last edited:
That's not fair; he changed his. :p
 
Thanks for the help guys. I have one more quick question. Now how do I make that text "Superior" disappear once the Save button is clicked. I got it working to save the number 9 (which displays Superior) for the category Professional Development. But when I move down to next category, the number is null, but not the text, it still displays Superior.
Thanks.
 
Call the after update code from the form's On Current Event:

Just type in:
Code:
score_opt_AfterUpdate
 
Call the after update code from the form's On Current Event:

Just type in:

Code:
score_opt_AfterUpdate


I still cannot get the "Superior" to disappear once Save button is clicked.
I put the code: score_opt_AfterUpdate
in the form On Current event.

The score_opt do disappear, just not the text in score_txt.
So I tried this code on current event and got debug error. score_txt_Afterupdate.

Thanks.
 
Ah, just spotted it. You need to keep what I said about the After Update, but also in the select case statement add this:
Code:
Private Sub score_opt_AfterUpdate()
Select Case score_opt
    Case 1, 2
        Me.score_txt = "Needs Improvement"
    Case 3 To 5
        Me.score_txt = "Satisfactory"
    Case 6 To 8
        Me.score_txt = "Above Average"
    Case 9, 10
        Me.score_txt = "Superior"
    [color=red]Case Else
        Me.score_txt = ""[/color]
End Select
End Sub
 
damn,

Bob you nailed it again. That was it, it worked like a charm. Thanks so much again.
Very cool.
I used the scales to give you positive feedback for reputation.

Good Day bud.
 
on the "OnCurrent" even to of the form, try
Code:
Me.score_opt.Requery
 

Users who are viewing this thread

Back
Top Bottom