Search Populating a list box.

Insentive

Registered User.
Local time
Today, 20:08
Joined
Mar 12, 2008
Messages
13
Im totally confused on how to do this, therefore i am here to seek help and advice. Bascially i want to search a table, get the results from the search to populate a list box.

And also to select aresult from a list box and then get results to populate another list box. My VB skills are intermediate its just dealing with acess is my problem :)
 
Why not just set the listbox's RowSource to be your query?
 
Hmm...

Im not sure how im going to loop the results of the search and display it in a listbox..
 
Ultimately what are you trying to do?? There may be a better way of doing it then two list boxes.
 
okay i will explain to you what im going todo.

The user searches into a text feild an organisation name, once found the user clicks and a list box is populated with employess to that organisation. Thats "ultimately" wha ti am trying to acheive.
 
For me (which I am no expert) I would do something like the DB that I posted before with another form. That would open on the dbl click in which it would show the company and below it the list box of employees.
 
Yerr thats what i was thinkign instead of over complicating things :D
 
you can't do everything with a single query - you often need lots of small queries to accomplish things

also generally you want to help users avoid having to type in things like organisation names, because a) it is slow and b) they may type it in an inconsistent manner each time

so - assuming you have tables

a) organisation (ref, org name etc)
b) employees (ref, organisation {ie linked to table a}, employeename etc)

then

1) have a query listing all the organisations in table a, and populate a combobox (say cboOrg) from that, then
2) have another query, which selects employees from table b, with one of the criteria being that the organisation ref is equal to the ref you just selected in the first combo box [criteria something like forms!myform!cboOrg]. Create a second cbobx with this query (say cboEmp)

now after you pick a company from cboOrg, it wont automatically refresh the cboEmp combobox - you have to force this

so the code you need in the cboOrg afterupdate event is
cboEmp.requery

as this will only refresh after you pick an item from the cboorg control, you may need to put some code in the form current event, to set both cboboxes appropriately as you move from record to record - it depends how you are building your database

--------
these are cascading combo boxes/list boxes
 

Users who are viewing this thread

Back
Top Bottom