List Box querying List Box

roosn

Registered User.
Local time
Today, 14:59
Joined
Jul 29, 2005
Messages
121
Windows XP
SSQl 2K BE
A2003 FE

Hi

i have 2 list boxes on a pop up form

they both using ADO queries as their source,

i use the left hand list box to search for documents and add selected documents to the right hand list box, which will synchronise with a main form form. i also delete some documents from the right kand list box, if not appropriate for the main form

my problem for the moment is an example is thus
LH list box values............RH list box values
1.................................3
2.................................4
3.................................5
4.................................6
5.................................8
7.................................9

if i press a button, how do i end up with values in the LH box, that are not in the RH, so the LH box returns
1
2
7

if i highlight all the RH box so they are selected, i can do this by using

' Loop through the selected items in the list box and build a text string
For Each varItem In Me!lstActual.ItemsSelected
strCriteria = strCriteria & "," & Me!lstActual.ItemData(varItem) & ""
Next varItem

' Remove the leading comma from the string
strCriteria = Right(strCriteria, Len(strCriteria) - 1)

i then build 'strCriteria' into the LH box query

but i would like to not have to highlight all the items in the RH box, is there another way round this?

thanks in advance
 
As both lists are populated via queries you can reuse the query as a recordset and use ADODB or DAODB to 'find' the record. Find is a method or both recordsets.
 
Dennisk
I take your point, and have that part now working, thank you. But i think i have now found a problem in my initial thought

My next objective, though is to add a selected row from the LH list box to the RH List Box, and then requery the LH list Box.

is the only way of acheiving this to create a local table to store the data in the RH List Box, then add/delete the data in the table, and at the end reconcile against the table on the server, oris there a better way

Thanks for your help

Roosn
 

Users who are viewing this thread

Back
Top Bottom