How refer to column of listbox in a query?

G

Guest

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)
 
S

StopThisAdvertising

Steve said:
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)

Hey Steve,

Look at the stats (Statcounter.com) to see the damage you have done to yourself.
Every time the link is shown, more and more people are reading about you.
http://home.tiscali.nl/arracom/SteveStats.html

Since you have been posting 'nice' the last couple of days the 'answering-machine' stops for now.
We will be watching you though...

ArnoR
 
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