Option Button to Populate Text Box on a Report

R

Rashid Khan

Hello All,
I am using Access 2002.
I have set Four Option Buttons in a Group as follows on a Form name [Print
Invoice]

Option 1 = None (this is also the default value)
Option 2 = Sale
Option 3 = CForm
Option 4 = Resale

I have a Report named [Invoice] where I have put two TextBox: txtbox1 and
txtbox2
I need to achieve the following:

txtbox1 = Sold Under -----> This should not be visible if Option 1 is
selected on [Print Invoice] Form and should be visible for all other options
viz 2, 3 and 4.

txtbox2 = ----> I want the value from the [Print Invoice] form to be
displayed here
i.e if option 1 is selected then txtbox2 should be 'blank' and if Option 2
is selected then the txtbox2 should show Sale, and if 3 is selected then
txtbox2 should show CForm and if Option 4 is selected then txtbox2 should
show Resale.

I have gone thru various NG under the heading Option Button and Text Box...
but could not find a suitble solution.

Any suggestions, work around to this problem would be greatly appreciated.

TIA
Rashid Khan
 
B

Byron

Take a look at using a Select Case statement in the After
Update event of the group box.

HTH

Byron
 
A

Allen Browne

Try using the Switch() function in the ControlSource of the text box on your
report, based on the value of the option group on your form.
 
R

Rashid Khan

Hi Allen and Byron

Sorry .. I am newbie and I would really appreciate an example of how to
achieve the solution.
Thanks for the time and effort

Allen Browne said:
Try using the Switch() function in the ControlSource of the text box on your
report, based on the value of the option group on your form.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rashid Khan said:
Hello All,
I am using Access 2002.
I have set Four Option Buttons in a Group as follows on a Form name [Print
Invoice]

Option 1 = None (this is also the default value)
Option 2 = Sale
Option 3 = CForm
Option 4 = Resale

I have a Report named [Invoice] where I have put two TextBox: txtbox1 and
txtbox2
I need to achieve the following:

txtbox1 = Sold Under -----> This should not be visible if Option 1 is
selected on [Print Invoice] Form and should be visible for all other options
viz 2, 3 and 4.

txtbox2 = ----> I want the value from the [Print Invoice] form to be
displayed here
i.e if option 1 is selected then txtbox2 should be 'blank' and if Option 2
is selected then the txtbox2 should show Sale, and if 3 is selected then
txtbox2 should show CForm and if Option 4 is selected then txtbox2 should
show Resale.

I have gone thru various NG under the heading Option Button and Text Box...
but could not find a suitble solution.

Any suggestions, work around to this problem would be greatly appreciated.

TIA
Rashid Khan
 
R

Rashid Khan

Hi Allen
I have used the following on the txtbox2 Control Source
=Switch(Forms![Print Invoice]!Frame24.DefaultValue=1,"",Forms![Print
Invoice]!Frame24.DefaultValue=2,"Sale",Forms![Print
Invoice]!Frame24.DefaultValue=3,"CForm",Forms![Print
Invoice]!Frame24.DefaultValue=4,"ReSale")

I copied the syntax from the NG and changed it accordingly but it does not
work.. What am I doing wrong.

Rashid Khan said:
Hi Allen and Byron

Sorry .. I am newbie and I would really appreciate an example of how to
achieve the solution.
Thanks for the time and effort

Allen Browne said:
Try using the Switch() function in the ControlSource of the text box on your
report, based on the value of the option group on your form.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rashid Khan said:
Hello All,
I am using Access 2002.
I have set Four Option Buttons in a Group as follows on a Form name [Print
Invoice]

Option 1 = None (this is also the default value)
Option 2 = Sale
Option 3 = CForm
Option 4 = Resale

I have a Report named [Invoice] where I have put two TextBox: txtbox1 and
txtbox2
I need to achieve the following:

txtbox1 = Sold Under -----> This should not be visible if Option 1 is
selected on [Print Invoice] Form and should be visible for all other options
viz 2, 3 and 4.

txtbox2 = ----> I want the value from the [Print Invoice] form to be
displayed here
i.e if option 1 is selected then txtbox2 should be 'blank' and if
Option
 
A

Allen Browne

Rashid, you are so close. Just drop the ".DefaultValue" bit, because you
want the Value, not the default.

The ControlSource will be:

=Switch([Forms]![Print Invoice]![Frame24] = 1, Null,
[Forms]![Print Invoice]![Frame24] = 2, "Sale", ...


--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rashid Khan said:
I have used the following on the txtbox2 Control Source
=Switch(Forms![Print Invoice]!Frame24.DefaultValue=1,"",Forms![Print
Invoice]!Frame24.DefaultValue=2,"Sale",Forms![Print
Invoice]!Frame24.DefaultValue=3,"CForm",Forms![Print
Invoice]!Frame24.DefaultValue=4,"ReSale")

I copied the syntax from the NG and changed it accordingly but it does not
work.. What am I doing wrong.

Rashid Khan said:
Hi Allen and Byron

Sorry .. I am newbie and I would really appreciate an example of how to
achieve the solution.
Thanks for the time and effort

Allen Browne said:
Try using the Switch() function in the ControlSource of the text box
on
your
report, based on the value of the option group on your form.

Hello All,
I am using Access 2002.
I have set Four Option Buttons in a Group as follows on a Form name [Print
Invoice]

Option 1 = None (this is also the default value)
Option 2 = Sale
Option 3 = CForm
Option 4 = Resale

I have a Report named [Invoice] where I have put two TextBox:
txtbox1
and
txtbox2
I need to achieve the following:

txtbox1 = Sold Under -----> This should not be visible if Option 1 is
selected on [Print Invoice] Form and should be visible for all other
options
viz 2, 3 and 4.

txtbox2 = ----> I want the value from the [Print Invoice] form to be
displayed here
i.e if option 1 is selected then txtbox2 should be 'blank' and if
Option
2
is selected then the txtbox2 should show Sale, and if 3 is selected then
txtbox2 should show CForm and if Option 4 is selected then txtbox2 should
show Resale.

I have gone thru various NG under the heading Option Button and Text
Box...
but could not find a suitble solution.

Any suggestions, work around to this problem would be greatly appreciated.

TIA
Rashid Khan
 
A

Amir Surani

Hi Allen,
Thanks Allen... The Switch() works fine.
Can u also help me with the first part of my problem. How can I make
txtbox1 Invisible if Option 1 is selected on [Print Invoice] Form and should
be visible for all other options viz 2, 3 and 4.



Allen Browne said:
Rashid, you are so close. Just drop the ".DefaultValue" bit, because you
want the Value, not the default.

The ControlSource will be:

=Switch([Forms]![Print Invoice]![Frame24] = 1, Null,
[Forms]![Print Invoice]![Frame24] = 2, "Sale", ...


--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rashid Khan said:
I have used the following on the txtbox2 Control Source
=Switch(Forms![Print Invoice]!Frame24.DefaultValue=1,"",Forms![Print
Invoice]!Frame24.DefaultValue=2,"Sale",Forms![Print
Invoice]!Frame24.DefaultValue=3,"CForm",Forms![Print
Invoice]!Frame24.DefaultValue=4,"ReSale")

I copied the syntax from the NG and changed it accordingly but it does not
work.. What am I doing wrong.

Rashid Khan said:
Hi Allen and Byron

Sorry .. I am newbie and I would really appreciate an example of how to
achieve the solution.
Thanks for the time and effort

Try using the Switch() function in the ControlSource of the text box on
your
report, based on the value of the option group on your form.

Hello All,
I am using Access 2002.
I have set Four Option Buttons in a Group as follows on a Form name
[Print
Invoice]

Option 1 = None (this is also the default value)
Option 2 = Sale
Option 3 = CForm
Option 4 = Resale

I have a Report named [Invoice] where I have put two TextBox: txtbox1
and
txtbox2
I need to achieve the following:

txtbox1 = Sold Under -----> This should not be visible if Option 1 is
selected on [Print Invoice] Form and should be visible for all other
options
viz 2, 3 and 4.

txtbox2 = ----> I want the value from the [Print Invoice] form to be
displayed here
i.e if option 1 is selected then txtbox2 should be 'blank' and if Option
2
is selected then the txtbox2 should show Sale, and if 3 is
selected
then
txtbox2 should show CForm and if Option 4 is selected then txtbox2
should
show Resale.

I have gone thru various NG under the heading Option Button and Text
Box...
but could not find a suitble solution.

Any suggestions, work around to this problem would be greatly
appreciated.

TIA
Rashid Khan
 
A

Allen Browne

Controlsource:
=IIf([Forms]![Print Invoice]![Frame24] = 1, Null, "Whateever you want it to
say for other cases here")

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Amir Surani said:
Thanks Allen... The Switch() works fine.
Can u also help me with the first part of my problem. How can I make
txtbox1 Invisible if Option 1 is selected on [Print Invoice] Form and should
be visible for all other options viz 2, 3 and 4.



Allen Browne said:
Rashid, you are so close. Just drop the ".DefaultValue" bit, because you
want the Value, not the default.

The ControlSource will be:

=Switch([Forms]![Print Invoice]![Frame24] = 1, Null,
[Forms]![Print Invoice]![Frame24] = 2, "Sale", ...
 
A

Amir Surani

Hi Allen,
Thanks a lot.. I have achieved what I wanted with your help.

You were really great.
Rashid
Allen Browne said:
Controlsource:
=IIf([Forms]![Print Invoice]![Frame24] = 1, Null, "Whateever you want it to
say for other cases here")

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Amir Surani said:
Thanks Allen... The Switch() works fine.
Can u also help me with the first part of my problem. How can I make
txtbox1 Invisible if Option 1 is selected on [Print Invoice] Form and should
be visible for all other options viz 2, 3 and 4.



Allen Browne said:
Rashid, you are so close. Just drop the ".DefaultValue" bit, because you
want the Value, not the default.

The ControlSource will be:

=Switch([Forms]![Print Invoice]![Frame24] = 1, Null,
[Forms]![Print Invoice]![Frame24] = 2, "Sale", ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top