How refer to column of listbox in a query?

M

mscertified

How refer to column of listbox in a query?

My SQL:
SELECT ID, Category
FROM tblCategory
WHERE ID IN (SELECT CategoryID FROM tblOrgCatXref WHERE OrgID =
[Forms]![frmOrgCat]![lstOrgs].Column(0));

But I get 'invalid function' error.
 
S

Steve

If the Bound Column property of lstOrgs is 1, Column(0) is the same value as
lstOrgs so you can remove ".Column(0)" from your expression.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
[email protected]
 
R

RoyVidar

mscertified said:
How refer to column of listbox in a query?

My SQL:
SELECT ID, Category
FROM tblCategory
WHERE ID IN (SELECT CategoryID FROM tblOrgCatXref WHERE OrgID =
[Forms]![frmOrgCat]![lstOrgs].Column(0));

But I get 'invalid function' error.

If the first column is the bound column, refer only to the listbox

WHERE OrgID = [Forms]![frmOrgCat]![lstOrgs]

If you are trying to refer to a column that isn't the bound column,
I think you'd need the Eval function

WHERE OrgID = Eval("[Forms]![frmOrgCat]![lstOrgs].Column(0)")
 
Top