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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple OptionsButtons 1

Status
Not open for further replies.

matrixindicator

IS-IT--Management
Sep 6, 2007
418
BE
Hey,

I have a few Option buttons on my form. Each button is a country. If a user select one or more he should run a query with these countries. So I can not use an option group (1 or more than one). Do I need to write a function to do this ?

Code:
OptBut1CountryUK true
OptBut2CountryES false
OptBut3CountryBE true

So the query should make a selection of UK and BE
 
Yes, you do. I would have used a multi-select listbox. It is easier.
 
As Remou said:

List box with Multi Select on
or
Individual radio buttons (NOT in option group)

List box is usually a better choice as it is much easier to add new values.

You then go through each selected item in the list box, and add them to the SQL string.

SeeThru
Synergy Connections Ltd - Telemarketing Services

 
ok, thanks to all, I found the code to use a multiple listbox, but the user ask for a specific option button list.
I wrote code. The value is stored in a textbox on my form.

The countrycode gets the value form the form, but I have a syntaxis problem. On test if I types in the countrycode in my query I got a result. If he gets the same value from my textbox, my query is showing anything ?

Code:
"NL" Or "UK"
[Forms]![frmTestView]![txtInfoCountry]

 
You will not be able to use OR, in a textbox it is text, not boolean. IN may suit:

WHERE Country IN ([Forms]![frmTestView]![txtInfoCountry])

txtInfoCountry='NL','UK'
 
Apologies, the above will only work if you build the query in code, for example.

[tt]strSQL="SELECT Country FROM tblCountry WHERE Country IN ( " _
& Me.txtInfoCountry & " )"[/tt]
 
Can I not use the query ?
It is a large query and the user can add or delete values, if my query is in code, he can't change the query anymore ?
 
I do not think you can use a query with a list in a textbox, however, it should be possible to use the option buttons:

[tt]=IIf([Forms]![frmTestView]!OptBut1CountryUK=true,"UK","")
OR IIf([Forms]![frmTestView]!OptBut2CountryES =true,"ES","")
OR IIf([Forms]![frmTestView]!OptBut3CountryBE=true,"BE","")[/tt]

You will get unwanted results with the above if any fields are equal to a zero-length string, that is,
 
Remou,

Thanks for you valuable help, I did a little test. I can do this in this wasy, so I do not need to programme something, just complete my IIF statements !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top