473,396 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Retrieve Value of Grouped Radio Button

132 100+
I have 2 radio buttons on a form...I need to know which was selected by the user in order to determine which report to send to the printer....This code is NOT getting it done...Any ideas??


If Forms!ReportForm![Option68].Value = True Then
Jan 31 '08 #1
3 22119
Delerna
1,134 Expert 1GB
I think its

If Forms!ReportForm![Option68].checked= True Then


By the way, get in the habbit of giving your controls sensible names.
It will make your code more readable and therefore easier to understand and change latter. Are you going to remember what Option68 is in 12 months after you relese it for use and a user encounters a problem has occurred and you need to track down what is causing it. A3 letter prefix in the name also tells you the type of control you are dealing with

optNameOfTheOptionControl
btnNameOfTheButtonControl
frmNameOfTheForm
tblNameOfTheTable
qryNameOfTheQuery

Just a suggestion !!
Jan 31 '08 #2
missinglinq
3,532 Expert 2GB
An Option Group isn't boolean, it doesn't return True/False. Instead, an Option Group returns the value assigned to the given button/checkbox. The first item in the Group returns a 1, the second a 2, and so forth. If the name of your Option Group frame is YourOptionFrame (clever isn't it?) this code will do the trick:

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourOptionFrame_Click()
  2.  Select Case YourOptionFrame
  3.    Case 1
  4.     'Code here to print "Report1"
  5.    Case 2
  6.     'Code here to print "Report2"
  7.  End Select
  8. End Sub
  9.  
You could also use

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourOptionFrame_Click()
  2.    If YourOptionFrame = 1 Then
  3.      'Code here to print "Report1"
  4.   ElseIf YourOptionFrame = 2 Then
  5.       'Code here to print "Report2"
  6.   End IF
  7.  End Sub
  8.  
With just a couple of choices it probably doesn't matter which you use, but the first example, using the Select Case construct, makes things much clearer when you have a number of choices.

You could use the same code behind a command button, to be clicked after chosing a button.

BTW, Delerna's advice on giving meaningful names to controls is spot on!

Linq ;0)>
Feb 1 '08 #3
Proaccesspro
132 100+
An Option Group isn't boolean, it doesn't return True/False. Instead, an Option Group returns the value assigned to the given button/checkbox. The first item in the Group returns a 1, the second a 2, and so forth. If the name of your Option Group frame is YourOptionFrame (clever isn't it?) this code will do the trick:

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourOptionFrame_Click()
  2.  Select Case YourOptionFrame
  3.    Case 1
  4.     'Code here to print "Report1"
  5.    Case 2
  6.     'Code here to print "Report2"
  7.  End Select
  8. End Sub
  9.  
You could also use

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourOptionFrame_Click()
  2.    If YourOptionFrame = 1 Then
  3.      'Code here to print "Report1"
  4.   ElseIf YourOptionFrame = 2 Then
  5.       'Code here to print "Report2"
  6.   End IF
  7.  End Sub
  8.  
With just a couple of choices it probably doesn't matter which you use, but the first example, using the Select Case construct, makes things much clearer when you have a number of choices.

You could use the same code behind a command button, to be clicked after chosing a button.

BTW, Delerna's advice on giving meaningful names to controls is spot on!

Linq ;0)>
Thanks, Guys! I'll incorporate the changes!
Feb 4 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: jason | last post by:
The following (likely far from imperfect code), reports a value of NaN in the j4 display. I suppose the problem is I am not really passing the "checked" value of the radio button via .value ......
4
by: mitch-co2 | last post by:
What I am trying to do is when someone clicks on the YES radio button I want the text field called MYTEXT to equal the text field named DATE. The below code works as long as I do NOT UN-COMMENT...
1
by: MickG | last post by:
I am trying to change the value of the variable "hard" according to which radio button is pressed and I am having no joy. Could anyone help me with this, the problematic section is marked with...
4
by: darrel | last post by:
I have a contact form that a person submits to the server. In ASP, you'd make a page, post the form to another page, which would grab the values and do somethign with them. in ASP.NET, it...
2
by: Rob | last post by:
Hi all, I've got multiple sets of radio button that are dynamically created in code and populated by a database query. The query returns about 20 recordsets with 3 radio buttons per recordset and...
0
by: larry jackson | last post by:
hello all im new to ASP. Net im using C# as the code behind problem: i created a form ( poll.aspx) that uses asp radio buttons so that the user can select an item. i want to retrieve and write...
0
by: zipzap | last post by:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:fp="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fp"> ...
1
by: sourcie | last post by:
I am changing an existing quiz found on "JavaScriptKit.com Multiple Choice Quiz" I have an image. Instead of using the radio buttons with the normal true/false question, I want to place two...
2
by: puT3 | last post by:
I have Customer table where there is a field called Company Type which store corporate or private. I want to retrieve the value in the table so it is diplayed on classic asp file in radio button. Im...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.