refer to a listbox column in the query qrid

H

HurlyGurly

I have a form with a listbox. & it's boundcolumn is set to 1 & is not
visible.
How can i refer to the other columns of the listbox in a query grid?

i.e. CityID is column2 - the BoundColumn is 1 and is hidden.
SELECT tblTest.*, tblTest.CityID FROM tbTest
WHERE (((tblTest.CityID)=[Forms]![frmTest]![lstTest]??????

Any help is appreciated.
Thanks
 
D

Duane Hookom

You can try:

SELECT tblTest.*
FROM tbTest
WHERE CityID=Eval("[Forms]![frmTest]![lstTest].Column(2)")
 
V

Van T. Dinh

WHERE tblTest.CityID=[Forms]![frmTest]![lstTest].Column(1)

The columns are zero-indexed so the first column has Index 0 and the second
column has index 1. Hence, the 1 above.

HTH
Van T. Dinh
MVP (Access)
 
H

HurlyGurly

Please forgive me if I emailed this to you directly. I must've pressed the
wrong button.


This works ok in VBA but not in a query criteria grid.
When i put the .Column(1) into the criteria expression,
I get a Error Function not defined.
The same is true for Mr. Hookums' suggestion.



Van T. Dinh said:
WHERE tblTest.CityID=[Forms]![frmTest]![lstTest].Column(1)

The columns are zero-indexed so the first column has Index 0 and the
second
column has index 1. Hence, the 1 above.

HTH
Van T. Dinh
MVP (Access)



HurlyGurly said:
I have a form with a listbox. & it's boundcolumn is set to 1 & is not
visible.
How can i refer to the other columns of the listbox in a query grid?

i.e. CityID is column2 - the BoundColumn is 1 and is hidden.
SELECT tblTest.*, tblTest.CityID FROM tbTest
WHERE (((tblTest.CityID)=[Forms]![frmTest]![lstTest]??????

Any help is appreciated.
Thanks
 
D

Duane Hookom

Did you place quotes around the form.control as my replay suggests? What was
your sql view based on my reply?

--
Duane Hookom
MS Access MVP


HurlyGurly said:
Please forgive me if I emailed this to you directly. I must've pressed the
wrong button.


This works ok in VBA but not in a query criteria grid.
When i put the .Column(1) into the criteria expression,
I get a Error Function not defined.
The same is true for Mr. Hookums' suggestion.



Van T. Dinh said:
WHERE tblTest.CityID=[Forms]![frmTest]![lstTest].Column(1)

The columns are zero-indexed so the first column has Index 0 and the
second
column has index 1. Hence, the 1 above.

HTH
Van T. Dinh
MVP (Access)



HurlyGurly said:
I have a form with a listbox. & it's boundcolumn is set to 1 & is not
visible.
How can i refer to the other columns of the listbox in a query grid?

i.e. CityID is column2 - the BoundColumn is 1 and is hidden.
SELECT tblTest.*, tblTest.CityID FROM tbTest
WHERE (((tblTest.CityID)=[Forms]![frmTest]![lstTest]??????

Any help is appreciated.
Thanks
 

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