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
(e-mail address removed)
 
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)")
 

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