Text box output controlled by Option group

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have scripts I need to display in a text box on a form. The script to be
displayed is dependent on what option is chosen in an option group. A given
script is about 500+ words. Do you know how I can do this?
 
Hello,

I have scripts I need to display in a text box on a form. The script to be
displayed is dependent on what option is chosen in an option group. A given
script is about 500+ words. Do you know how I can do this?

Here is a generic solution.
Just a few choices?
Code the AfterUpdate event of the OptionGroup:

If Me![OptionGroupName] = 1 Then
[ControlName] = "This "
Elseif Me![OptionGroupName] = 2 Then
[ControlName] = "That"
Else
[ControlName] = "Something Else"
End If

Many choices use a Select Case.
 
I think this is the correct way of returning OptionGroup values, but I didn't
test this first. Put it on a button_click event perhaps.

Select Case OptionGroup1
Case Is = 0
Text1 = "My Text # 1"
Case Is = 1
Text1 = "My Text # 2"
'etc.
End Select

The source of the text can also be a DLookup from a memo field in a table,
something like this: Dlookup"[fldNotes]","[tblNotes]","[fldID] = " &
OptionGroup1 + 1

For the first option, OptionGroup1 has a value of 0, so the DLookup would
pick fldID #1, the second has a value of 1, so DLookup would find #2, etc.
 
Brian,
It looks like this:
Private Sub optngrpScripts_Click()
Select Case optngrpScripts
Case Is = 0
tbxScripts = "My Text # 1"
Case Is = 1
tbxScripts = "My Text # 2"
End Select

End Sub

optngrpScripts is the Option Group which has the four option buttons. The
dugger comes up when I run the form and selecting any of the buttons cause no
changes in Text Box named tbxScripts. Any suggestions?

Brian said:
I think this is the correct way of returning OptionGroup values, but I didn't
test this first. Put it on a button_click event perhaps.

Select Case OptionGroup1
Case Is = 0
Text1 = "My Text # 1"
Case Is = 1
Text1 = "My Text # 2"
'etc.
End Select

The source of the text can also be a DLookup from a memo field in a table,
something like this: Dlookup"[fldNotes]","[tblNotes]","[fldID] = " &
OptionGroup1 + 1

For the first option, OptionGroup1 has a value of 0, so the DLookup would
pick fldID #1, the second has a value of 1, so DLookup would find #2, etc.

Rod said:
Hello,

I have scripts I need to display in a text box on a form. The script to be
displayed is dependent on what option is chosen in an option group. A given
script is about 500+ words. Do you know how I can do this?
 
This looks correct. As a quick test, try putting this right before the Select
Case:

MsgBox optngrpScripts

Does it come back with a valid value (i.e. the one associated with the
option)? If not, then the option group may not be constructed properly.

Also, depending on how you set up your option group, the value of the first
one is probably 1, not 0, and the second one is 2, not 1, etc. That was my
error in round 1.

You might try re-creating the option group using the wizard to make sure it
is all constructed correctly (i.e. the values assigned to each option). It
asks for the label names and the value to be associated with each one.

Rod said:
Brian,
It looks like this:
Private Sub optngrpScripts_Click()
Select Case optngrpScripts
Case Is = 0
tbxScripts = "My Text # 1"
Case Is = 1
tbxScripts = "My Text # 2"
End Select

End Sub

optngrpScripts is the Option Group which has the four option buttons. The
dugger comes up when I run the form and selecting any of the buttons cause no
changes in Text Box named tbxScripts. Any suggestions?

Brian said:
I think this is the correct way of returning OptionGroup values, but I didn't
test this first. Put it on a button_click event perhaps.

Select Case OptionGroup1
Case Is = 0
Text1 = "My Text # 1"
Case Is = 1
Text1 = "My Text # 2"
'etc.
End Select

The source of the text can also be a DLookup from a memo field in a table,
something like this: Dlookup"[fldNotes]","[tblNotes]","[fldID] = " &
OptionGroup1 + 1

For the first option, OptionGroup1 has a value of 0, so the DLookup would
pick fldID #1, the second has a value of 1, so DLookup would find #2, etc.

Rod said:
Hello,

I have scripts I need to display in a text box on a form. The script to be
displayed is dependent on what option is chosen in an option group. A given
script is about 500+ words. Do you know how I can do this?
 
After recreating and opting to store the value for later use it looks like
this:
Private Sub optngrpScripts_Click()

Select Case optngrpScripts
MsgBox optngrpScripts
Case Is = 0
tbxScripts = "My Text # 1"
Case Is = 1
tbxScripts = "My Text # 2"
End Select

End Sub
and the VB window pops up after clcking all of them a few times and states
"Object doesn't support this property or method ( run-time error '438'). The
text box never changed.

Brian said:
This looks correct. As a quick test, try putting this right before the Select
Case:

MsgBox optngrpScripts

Does it come back with a valid value (i.e. the one associated with the
option)? If not, then the option group may not be constructed properly.

Also, depending on how you set up your option group, the value of the first
one is probably 1, not 0, and the second one is 2, not 1, etc. That was my
error in round 1.

You might try re-creating the option group using the wizard to make sure it
is all constructed correctly (i.e. the values assigned to each option). It
asks for the label names and the value to be associated with each one.

Rod said:
Brian,
It looks like this:
Private Sub optngrpScripts_Click()
Select Case optngrpScripts
Case Is = 0
tbxScripts = "My Text # 1"
Case Is = 1
tbxScripts = "My Text # 2"
End Select

End Sub

optngrpScripts is the Option Group which has the four option buttons. The
dugger comes up when I run the form and selecting any of the buttons cause no
changes in Text Box named tbxScripts. Any suggestions?

Brian said:
I think this is the correct way of returning OptionGroup values, but I didn't
test this first. Put it on a button_click event perhaps.

Select Case OptionGroup1
Case Is = 0
Text1 = "My Text # 1"
Case Is = 1
Text1 = "My Text # 2"
'etc.
End Select

The source of the text can also be a DLookup from a memo field in a table,
something like this: Dlookup"[fldNotes]","[tblNotes]","[fldID] = " &
OptionGroup1 + 1

For the first option, OptionGroup1 has a value of 0, so the DLookup would
pick fldID #1, the second has a value of 1, so DLookup would find #2, etc.

:

Hello,

I have scripts I need to display in a text box on a form. The script to be
displayed is dependent on what option is chosen in an option group. A given
script is about 500+ words. Do you know how I can do this?
 
1. When you get the error and click Debug, which line seems to be generating
the error?

2. Try removing the entire Select Case section except the MsgBox in the Sub
and see if it comes up with a value for optngrpScripts or if you still get
the error. Does it give you the correct number for the option selected, does
it do nothing, or does it generate an error? If an error, clilck debug and
note which line contains the error.

Private Sub optngrpScripts_Click()
MsgBox optngrpScripts
End Sub

3. Which version of Access are you using?

Rod said:
After recreating and opting to store the value for later use it looks like
this:
Private Sub optngrpScripts_Click()

Select Case optngrpScripts
MsgBox optngrpScripts
Case Is = 0
tbxScripts = "My Text # 1"
Case Is = 1
tbxScripts = "My Text # 2"
End Select

End Sub
and the VB window pops up after clcking all of them a few times and states
"Object doesn't support this property or method ( run-time error '438'). The
text box never changed.

Brian said:
This looks correct. As a quick test, try putting this right before the Select
Case:

MsgBox optngrpScripts

Does it come back with a valid value (i.e. the one associated with the
option)? If not, then the option group may not be constructed properly.

Also, depending on how you set up your option group, the value of the first
one is probably 1, not 0, and the second one is 2, not 1, etc. That was my
error in round 1.

You might try re-creating the option group using the wizard to make sure it
is all constructed correctly (i.e. the values assigned to each option). It
asks for the label names and the value to be associated with each one.

Rod said:
Brian,
It looks like this:
Private Sub optngrpScripts_Click()
Select Case optngrpScripts
Case Is = 0
tbxScripts = "My Text # 1"
Case Is = 1
tbxScripts = "My Text # 2"
End Select

End Sub

optngrpScripts is the Option Group which has the four option buttons. The
dugger comes up when I run the form and selecting any of the buttons cause no
changes in Text Box named tbxScripts. Any suggestions?

:

I think this is the correct way of returning OptionGroup values, but I didn't
test this first. Put it on a button_click event perhaps.

Select Case OptionGroup1
Case Is = 0
Text1 = "My Text # 1"
Case Is = 1
Text1 = "My Text # 2"
'etc.
End Select

The source of the text can also be a DLookup from a memo field in a table,
something like this: Dlookup"[fldNotes]","[tblNotes]","[fldID] = " &
OptionGroup1 + 1

For the first option, OptionGroup1 has a value of 0, so the DLookup would
pick fldID #1, the second has a value of 1, so DLookup would find #2, etc.

:

Hello,

I have scripts I need to display in a text box on a form. The script to be
displayed is dependent on what option is chosen in an option group. A given
script is about 500+ words. Do you know how I can do this?
 
Back
Top