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!

How do u use a combo box as the criteria value in a query?

Status
Not open for further replies.

Rahel

Programmer
Feb 16, 2000
30
GB
How do u specify the criteria value in a query to be read from a combo list on a form. I want to use the value in a combo box on a form to limit the results of a query.<br>
<br>
If possible, an example of how to write the expression in a FoxPro query would be helpful.<br>
<br>
For example in Access, the way I would do this is:<br>
<br>
In the criteria part in an Access query, you would enter the location of the combo box as an expression ie. <br>
<br>
[Forms]![frmReporting]![Combo box name]<br>
<br>
therefore when the query is run, the value selected on the combo box will be used to limit the records.<br>

 
Hi, Rahel.<br>
<br>
You should be able to read the Value property, which would be in the same data type as the underlying RowSource.<br>
<br>
For example, if you had a combo box cboState on your form, you could access like this:<br>
<br>
ThisForm.cboState.Value<br>
<br>
(assuming no intervening containers like PageFrames).<br>
<br>
You didn't elaborate on what you meant by &quot;query&quot;, but an example of using it in an SQL Select would be:<br>
<br>
SELECT * FROM MYTABLE WHERE STATE=ThisForm.cboState.Value<br>
<br>
You could also use the ListIndex property to tell you the *number* of the item within the list of choices.<br>
<br>
I hope this helps...<br>
<br>
Robert Bradley<br>
<A HREF=" TARGET="_new"><br>
 
You can also use a parameterized view.<br>
For Example:<br>
<br>
CREATE VIEW MyView AS<br>
SELECT * FROM States WHERE Country = ?cCountry<br>
<br>
Of Course, you can also design the view in the View Designer.<br>
Then in the Interactivechange of the Combobox Write somewhat like this:<br>
<br>
cCountry = This.Value<br>
Requery('MyView')<br>
Thisform.Refresh<br>
<br>
Excusame if my English is not good.<br>
Edwin Dalorzo<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top