Option Group Value To Text Box

fenhow

Registered User.
Local time
Today, 11:45
Joined
Jul 21, 2004
Messages
599
Hi,

I have an option group on a form.

1=Yes and 2=No

I have placed a txtBox on the form and am trying to populate it according to what is selected in the option group.

So, if the user selects option 1 the txtBox is updated is says Yes.

Is this possible?

Thanks.

Fen How
 
Here's two ways:

Code:
Private Sub YourFrameName_AfterUpdate()
 Select Case YourFrameName
  Case 1
    Me.TxtBox = "Yes"
  Case 2
    Me.TxtBox = "No"
 End Select
End Sub
Code:
Private Sub YourFrameName_AfterUpdate()
   If Me.YourFrameName = 1 Then Me.TxtBox = "Yes"
   If Me.YourFrameName = 2 Then Me.TxtBox = "No"
End Sub
 
Hello, it works for me in this way:
Private Sub TxtMotivo_AfterUpdate()
Dim B As Integer

Select Case Me![TxtMotivo]
Case 1
Me![Tipointeres] = "NAT"
B = 1
Case 2
Me![Tipointeres] = "CONT"
B = 2
Case 3
Me![Tipointeres] = "CULT"
B = 3
End Select


DoCmd.RunCommand acCmdSaveRecord
wait 1000
B = TxtMotivo.Value
End sub


My problem is that the option group does not mark with the point the selected option.
It seems that TxtMotivo value is erased


I try to update the field in the table with the form, the only issue is that there are no selection point on the option group.
So yes, I think I want to update the caption of the option group button,
Thanks in advance
 
Last edited:
Hello, it works for me in this way:


Private Sub TxtMotivo_AfterUpdate()
Select Case Me![TxtMotivo]
Case 1
Me![Tipointeres] = "NAT"
Case 2
Me![Tipointeres] = "CONT"
Case 3
Me![Tipointeres] = "CULT"
End Select
End Sub


My problem is that the option group does not mark with the point the selected option.
It seems that TxtMotivo value is erased

I could make several guesses as to the answer you want, however it would be much better if you provided a bit more information.

It's not clear if you are trying to update the caption of the option group button, or if you are trying to add the text to the underlying data behind the option group.
 
Then you need to store both the number and the text in a field for each, like in the attached database.
 

Attachments

Another (easier) solution is using a combo box.
 

Attachments

Then you need to store both the number and the text in a field for each, like in the attached database.


It works perfect, but I don't realize how you did this...
I try to add a fieldText, but I can't change the field to fieldNumber.


Sorry for my... :) and thanks again


This is my archive
 

Attachments

Last edited:
Here you are, database attached.
Have you tried the solution in post #7, it is much easier.
 

Attachments

Here you are, database attached.
Have you tried the solution in post #7, it is much easier.


I'm looking for difference with mine "option group almost.accdb" and I can't find. The only difference is that mine gives and error 2465...


working)


Private Sub TxtMotivo_AfterUpdate()

Select Case Me![TxtMotivo]
Case 1
Me![TipointeresText] = "Natural"
Case 2
Me![TipointeresText] = "Cultural histórico"
Case 3
Me![TipointeresText] = "Cultural Contemporáneo"

End Select
DoCmd.RunCommand acCmdSaveRecord

End Sub


But your code is diferent and work...
 
Last edited:
did notice in one of the tables are you saving inages to the table if so you shoud save all images/files in a folder and link them i have seen code for that on here if i come accross it again I'll post the link
 
I'm looking for difference with mine "option group almost.accdb" and I can't find.
Okay - see below, picture and code:
attachment.php


Code:
  Case 1
      Me![B][COLOR=Red][Tipo interés][/COLOR][/B] = "Natural"
    B = 1
  Case 2
    Me![B][COLOR=red][Tipo interés][/COLOR] [/B]= "Cultural histórico"
  B = 2
  Case 3
    Me![B][COLOR=red][Tipo interés][/COLOR][/B] = "Cultural Contemporáneo"
    B = 3
 

Attachments

  • Tipointeres.jpg
    Tipointeres.jpg
    93.5 KB · Views: 955
Okay - see below, picture and code:
attachment.php


Code:
  Case 1
      Me![B][COLOR=Red][Tipo interés][/COLOR][/B] = "Natural"
    B = 1
  Case 2
    Me![B][COLOR=red][Tipo interés][/COLOR] [/B]= "Cultural histórico"
  B = 2
  Case 3
    Me![B][COLOR=red][Tipo interés][/COLOR][/B] = "Cultural Contemporáneo"
    B = 3


Sorry but why would you want to store the option text values when you should only be storing the option group value 1-3 as they are linked the correct txt value would have been selected on each record?
 
Sorry but why would you want to store the option text values when you should only be storing the option group value 1-3 ..
Because the option text isn't what OP wants to show, he wants a completely different text.
In post #7 I've made an easier solution with a combo box and a table holding the wanted text.
 
yes I see that the value is updating a combo box It's not my program but I would have used a list or combo box without the option group with the complete text but everybody does things in there own way
 

Users who are viewing this thread

Back
Top Bottom