Solved Write Optionbox value as text

Mylton

Member
Local time
Yesterday, 18:34
Joined
Aug 3, 2019
Messages
136
Good afternoon
Sorry for the language, but I don't speak English well.

I know that it is necessary to create a decoupled option group for this value to be written as text.
I even found a topic, but the example was no longer present.

In doubt I have 1 form and 1 table

I would like the value of option 1 to be registered as not seen, or practically not seen, option 2 as seen and option 3 as clearly seen.

I created a MSG box to show the user their choice.

But I can't write the text itself.

Private Sub Frame1_Click()
Dim Tbl1 As Integer
Select Case Me.Frm1
Case Is = 1
MsgBox ("not seen, or barely seen")
' Me.Opcao1.Value = "not seen, or barely seen"

' DoCmd.RunSQL "UPDATE table1 SET table1.Frame1" = Me.Option1

' DoCmd.RunSQL "UPDATE table1 SET table1.Option1.Value "


Case Is = 2
MsgBox("See You")
' Me.Opcao2.Value = "is seen"
Case Is = 3
MsgBox("See Clearly")
' Me.Opcao3.Value = "is clearly seen"
End Select

End Sub




Some way.

Thanks
 

Attachments

in a table tOptValues
1, not seen, or barely seen
2, is seen
3. is clearly seen

this table can be used in a query to translate the opt box.
or to show the text on screen using a combo to show get the text via the value.
 
The best solution is to leave the options as 1,2,3 and store those values. Show them with either the option group or a combo if you don't have room for the option group on the form/report. If you have logic in VBA that depends on the value of the option group, use a Case statement to add logic for each of the three cases.
 
Ok
Pat Hartman

any reading tips so I can study coko to do this in VBA?
because I don't have the slightest idea of how to implement it.
thanks
 
Here is an amended file for you. When you select an option, it will write the appropriate text to the Reply 1 field. Please note the changes to the VBA Select Case code. It was incorrect.
 

Attachments

It sure suits me.
Thank you very much.

Good week to everyone.
 
@LarryE Did you notice that the option group does not populate when you open the form. This is why we do not do it this way.

The Option group cannot be bound to a text field. THEREFORE, unless you want code everywhere, to convert from and to the option values, you store the Numeric values, just like you store the numeric value for a combo.

Take a look at the form I created. It requires NO code to operate correctly.

I bound both the option group AND a combo to the same field - in reality, you would NEVER do this on the same form. I did it to show how it works. Change the combo and the option group changes. Change the option group and the combo changes.

Where it gets awkward is if you need to write code to do something differently depending on the value. Now, it is not so nice. Instead of referencing a string, you have to use the numbers 1,2,3. When I do this, I always add a comment to explain what the number means.
 

Attachments

good morning everyone
thanks for this teaching.

I wish you a great week
 

Users who are viewing this thread

Back
Top Bottom