By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,526 Members | 1,888 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,526 IT Pros & Developers. It's quick & easy.

Query influenced by combo box value

P: n/a
Hello,
I have a continuous form with a combo box inside. From the combo box I can
pick some values which, by the "after-update" event, change some other combo
box values determined by a query.
(i.e. I have some tree names and depending on what tree I pick on the other
combo box I can pick its fruits and other properties)

Now, mine is a continous form, and whenever I pick a value from the first
combo box the second one correctly shows the updated values, but the first
combo influences all records' combos in the form.
This way, following with my trees example, if I change the third tree all
combo boxes with properties for other trees change showing properties
related to this tree.

This is the query of the second combo box that depends on the first one
(IDTree):

SELECT DISTINCTROW TblProps.IDProp, TblProps.PropName, TblProps.IDTree FROM
TblProps WHERE (TblProps.IDTree=CurrentRecord.IDTree.value)

What am I doing wrong?

Thanks in advance,
G
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I have a listbox with 13 columns in it, the bound column being column
1. I want to query a table with the list of values in the bound column
being used as the criteria. It doesn't matter to me if anything is
selected, I just want the entire list of values from the bound column.

I know I could do this looping through the listbox, but I'd rather
avoid that.

I'm thinking something like this:

"SELECT * FROM tblCustomers WHERE CustomerID IN " &[list of values
from bound column] & ""

the customerid is stored as a long int

Is it possible? Is there another way to do what I want without looping
through the listbox?
Any help would be really appreciated.

thank you

Nov 12 '05 #2

P: n/a
DFS
"arejay" <ar*******@yahoo.com> wrote in message
news:gr********************************@4ax.com...
I have a listbox with 13 columns in it, the bound column being column
1. I want to query a table with the list of values in the bound column
being used as the criteria. It doesn't matter to me if anything is
selected, I just want the entire list of values from the bound column.

I know I could do this looping through the listbox, but I'd rather
avoid that.

I'm thinking something like this:

"SELECT * FROM tblCustomers WHERE CustomerID IN " &[list of values
from bound column] & ""

arejay,

Do you mean the value in the bound column from every row in the listbox? as
in SELECT * FROM TABLE WHERE CustomerID = 1 or CustomerID = 2 or CustomerID
= 3.... (where 1,2 and 3 are found in the bound column in the listbox)?

If that's the case, save the listbox rowsource as a query (if it's not
already) and use it in another query, something like:

SELECT T.*
FROM TABLE T INNER JOIN listBoxQuery Q
ON T.CustomerID = Q.CustomerID;
the customerid is stored as a long int

Is it possible? Is there another way to do what I want without looping
through the listbox?
Any help would be really appreciated.

thank you

Nov 12 '05 #3

P: n/a
arejay <ar*******@yahoo.com> wrote in message news:<gr********************************@4ax.com>. ..
I have a listbox with 13 columns in it, the bound column being column
1. I want to query a table with the list of values in the bound column
being used as the criteria. It doesn't matter to me if anything is
selected, I just want the entire list of values from the bound column.

I know I could do this looping through the listbox, but I'd rather
avoid that.

Yeah, I'd like to make lots of money, but I'd rather not work. Umm...
Wake up, you're dreaming. That's the ONLY way to get all the values
from a listbox, well, if your MultiSelect property is set to True.
There's code at www.mvps.org/access that will loop through the
listbox... and you'll have to build the SQL on the fly. Maybe create
a function to concatenate the items in the Selected collection of the
listbox and then use that.
Nov 12 '05 #4

P: n/a
DFS

"Pieter Linden" <pi********@hotmail.com> wrote in message
news:bf*************************@posting.google.co m...
arejay <ar*******@yahoo.com> wrote in message news:<gr********************************@4ax.com>. ..
I have a listbox with 13 columns in it, the bound column being column
1. I want to query a table with the list of values in the bound column
being used as the criteria. It doesn't matter to me if anything is
selected, I just want the entire list of values from the bound column.

I know I could do this looping through the listbox, but I'd rather
avoid that.

Yeah, I'd like to make lots of money, but I'd rather not work. Umm...
Wake up, you're dreaming. That's the ONLY way to get all the values
from a listbox, well, if your MultiSelect property is set to True.


It's always a bad idea to say ONLY or ALWAYS (a little recursive
disclaimer..)

If the listbox has a query for a rowsource, you can get the values from the
query. Maybe you misread - he doesn't say they have to be selected, just in
the list.


There's code at www.mvps.org/access that will loop through the
listbox... and you'll have to build the SQL on the fly. Maybe create
a function to concatenate the items in the Selected collection of the
listbox and then use that.

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.