how do I link a list box to another list box (1 Viewer)

MIkeD666

Registered User.
Local time
Today, 05:43
Joined
Jan 12, 2019
Messages
59
Hi all, I hope you can help me.
I want to use the selected row in a list box , which has 3 fields in it. CustID, CustADD and CustName.
that will then populate a second list box with invoice details where the custid from a invoice table is = to the custID in the first list box.

So that I have a number of invoice details for the CustID listed in the list box 2

once this is found and then select a row for this listbox to product report showing the invoice details..

The aim is to allow staff to look at a preview list of invoice details of any customer and then select the correct invoice and produce a report showing the full invoice details

Miked666
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:43
Joined
Sep 21, 2011
Messages
14,288
Set the rowsource for listbox2 in the afterupdate event of listbox1 referring to the custid in listbox1. No need for a requery.
Then in listbox2 perhaps use the double click event to open the report and again referring to the invoice ID in the open report command.

 

CJ_London

Super Moderator
Staff member
Local time
Today, 13:43
Joined
Feb 19, 2013
Messages
16,610
alternatively if the rowsource is sql code (i.e. not a queryname) you can reference the listbox1 as part of your query e.g.

SELECT *
FROM tblInvoices
WHERE CustID=[listbox1]

then in the change event of listbox1 put 'listbox2.requery'. If your listbox is actually a combobox, then use the afterupdate event instead.
 

MIkeD666

Registered User.
Local time
Today, 05:43
Joined
Jan 12, 2019
Messages
59
Hi all, I hope you can help me.
I want to use the selected row in a list box , which has 3 fields in it. CustID, CustADD and CustName.
that will then populate a second list box with invoice details where the custid from a invoice table is = to the custID in the first list box.

So that I have a number of invoice details for the CustID listed in the list box 2

once this is found and then select a row for this listbox to product report showing the invoice details..

The aim is to allow staff to look at a preview list of invoice details of any customer and then select the correct invoice and produce a report showing the full invoice details

Miked666
Hi thank for the info, I just got time to work on it today. thanks
 

MIkeD666

Registered User.
Local time
Today, 05:43
Joined
Jan 12, 2019
Messages
59
alternatively if the rowsource is sql code (i.e. not a queryname) you can reference the listbox1 as part of your query e.g.

SELECT *
FROM tblInvoices
WHERE CustID=[listbox1]

then in the change event of listbox1 put 'listbox2.requery'. If your listbox is actually a combobox, then use the afterupdate event instead.
Thank for the info, was a great help.
 

Users who are viewing this thread

Top Bottom