Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Option Button Control

Status
Not open for further replies.

Kelvin

Programmer
Apr 25, 2000
23
AU
Please Help,
I have 12 option buttons on form with option value number's 1 through to 12 recorded in table eg: lngselect
When I click say button 1 I would like it to do a calculation eg: Expr1:[lngInput]*10 and output to form.
When I click say button 2 I would like it to do a calculation eg: Expr1:[lngInput]*34 and output to form.
as so forth

I have a Query setup also
Thanking You
Kelvin
 
Just a shot in the dark (since I'm not really sure how you are doing everything), but this might give you an alternative to achieve what you want.


If these Option Buttons are part of an Option Group (inside a frame) then you probably want to do a Select Case routine in the AfterUpdate Event for the Option Group

i.e.
name of the form with the Option Group is frmGetOptions
name of Option Group is fraOptions
name of textbox where data is to be displayed is txtData (txtData is on the same form with the Option Group)

Sub fraOptions_AfterUpdate()
Select Case fraOptions
Case 1
txtData = lngInput * 10
Case 2
txtData = lngInput * 34
Case 3
txtData = lngInput * some#
Case 4
txtData = lngInput * some#
Case 5
txtData = lngInput * some#
Case 6
txtData = lngInput * some#
Case 7
txtData = lngInput * some#
Case 8
txtData = lngInput * some#
Case 9
txtData = lngInput * some#
Case 10
txtData = lngInput * some#
Case 11
txtData = lngInput * some#
Case 12
txtData = lngInput * some#
End Select
End Sub

If they are 12 separate option buttons then you have a lot more coding to do. I'd recommend using an Option Group, its a lot easier

if the "output to form" you are talking about is on the same form as the option group, then the above code displays the results. If the form is a different form then you would need to reference the txtData textbox in you query for the new form. Use an expression field with the criteria set to

[Forms]![frmGetOptions].[txtData]

and frmGetOptions would have to remain open when you ran the query.

OR

instead of sending the results of the Select Case to a textbox you could sent it to a public variable, and then call that in your query (via a Public Function). You use an expression field and for the criteria use the Public Function, and the form frmGetOptions would not have to be open when you ran the query.

i.e. instead of txtData being a textbox we'll use it as the name of a Public Variable

Public Function OptValue()
OptValue = txtData
End Function

then the criteria row in the query for the expression field would be
OptValue()



HTH
PaulF
 
PaulF

I used your code and it worked Fine,

Thanking You for your help

regards kelvin [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top