Connecting Tech Pros Worldwide Forums | Help | Site Map

Query influenced by combo box value

Giulio
Guest
 
Posts: n/a
#1: Nov 12 '05
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

arejay
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Query influenced by combo box value


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

DFS
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Query influenced by combo box value


"arejay" <arejay001@yahoo.com> wrote in message
news:grpvsvo1d1ptn3tac0gh7q4i2cu6m64fo6@4ax.com...[color=blue]
> 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] & ""[/color]


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;


[color=blue]
> 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
>[/color]


Pieter Linden
Guest
 
Posts: n/a
#4: Nov 12 '05

re: Query influenced by combo box value


arejay <arejay001@yahoo.com> wrote in message news:<grpvsvo1d1ptn3tac0gh7q4i2cu6m64fo6@4ax.com>. ..[color=blue]
> 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.
>[/color]
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.
DFS
Guest
 
Posts: n/a
#5: Nov 12 '05

re: Query influenced by combo box value



"Pieter Linden" <pietlinden@hotmail.com> wrote in message
news:bf31e41b.0312051024.3e87b97@posting.google.co m...[color=blue]
> arejay <arejay001@yahoo.com> wrote in message[/color]
news:<grpvsvo1d1ptn3tac0gh7q4i2cu6m64fo6@4ax.com>. ..[color=blue][color=green]
> > 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.
> >[/color]
> 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.[/color]

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.




[color=blue]
> 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.[/color]


Closed Thread


Similar Microsoft Access / VBA bytes