list box value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have two lists boxes on my form.

first list:
queries from an acces query 3 fields circuit, route, number

second list
has two fields route, size
On this second list list I want to populate the rowsource using vb
my row source will look something like this:

txtroute = ???I need this to equal the route selected in the first list
strsql = "SELECT qryCircuitRoute.Route qryCircuitRoute.Size, FROM
qryCircuitRoute WHERE (((qryCircuitRoute.Route)=""" & txtroute & """));"
listCircList.RowSource = strsql

I do not have any fields saved to any table from the first list.
 
Sorry, about the second question, why the values are not saved in the table,
did you bounded the list box to any of the fields in the table?
Check the ControlSource Property of the list box
 
Try this, the count of the column start from 0, so the route will be 1

txtroute = Me.ListBox1name.column(1) ' Strat from 0
strsql = "SELECT qryCircuitRoute.Route qryCircuitRoute.Size, FROM
qryCircuitRoute WHERE (((qryCircuitRoute.Route)='" & txtroute & "'"));"
listCircList.RowSource = strsql
==============================================
But you can create the rowsource of list 2:

SELECT qryCircuitRoute.Route qryCircuitRoute.Size, FROM
qryCircuitRoute WHERE
(((qryCircuitRoute.Route)=Forms![Formname]![ListBox1Name]));

And all you need to do is, on the after update of list 1 write the code
Me.ListBox2Name.Requery
===============================================

In God We Trust - Everything Else We Test
 
Thank you for the help

Ofer said:
Try this, the count of the column start from 0, so the route will be 1

txtroute = Me.ListBox1name.column(1) ' Strat from 0
strsql = "SELECT qryCircuitRoute.Route qryCircuitRoute.Size, FROM
qryCircuitRoute WHERE (((qryCircuitRoute.Route)='" & txtroute & "'"));"
listCircList.RowSource = strsql
==============================================
But you can create the rowsource of list 2:

SELECT qryCircuitRoute.Route qryCircuitRoute.Size, FROM
qryCircuitRoute WHERE
(((qryCircuitRoute.Route)=Forms![Formname]![ListBox1Name]));

And all you need to do is, on the after update of list 1 write the code
Me.ListBox2Name.Requery
===============================================

In God We Trust - Everything Else We Test


Cynthia said:
I have two lists boxes on my form.

first list:
queries from an acces query 3 fields circuit, route, number

second list
has two fields route, size
On this second list list I want to populate the rowsource using vb
my row source will look something like this:

txtroute = ???I need this to equal the route selected in the first list
strsql = "SELECT qryCircuitRoute.Route qryCircuitRoute.Size, FROM
qryCircuitRoute WHERE (((qryCircuitRoute.Route)=""" & txtroute & """));"
listCircList.RowSource = strsql

I do not have any fields saved to any table from the first list.
 
Back
Top