Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best way to handle lists and sub lists

Status
Not open for further replies.

LowBrow

Technical User
Jun 1, 2001
100
US
I am working on a contact management database. Each contact may have resources. We are a non-profit employment agency for people with disabilities, so these resources are types of employment offered from the contact. The resources are described in two tables JobClass and JobName. An example of a JobClass is 'Customer Service', and an example of a JobName within 'Customer Service' would be 'Cashier'. I need to be able to view, add or delete resources in the form, but I am having mixed success with mostly failure, and I know there must be an easier way.
My most successful method has been with main form with the contact info, and a list of assigned Classes and JobNames (these are subforms, continuous forms) and a subform containing 2 combo boxes (class and jobname), a frame option group with add or delete options, and the add and delete buttons.
I have code that accurately lists JobClasses not selected for the current contact, or lists all current JobClasses (to select one to be deleted). And since the JobNames available is dependant on a JobClass having already been selected, I have created code which accurately produces a list of available jobnames (that are both not currently selected for the contact and are associated with job classes already selected for the contact). Similarly, I can produce a list of JobNames currently assigned to the contact to be deleted. All of these functions work correctly, and I can delete or add items. But I can only do it once, and I can only do it for the first contact. I am having problems with refreshing the view after adding or deleting, or moving to a new record. I am also having problems with refreshing the individual lists after changes.
Okay, that was a long explanation, and I hope it was clear. First off, am I going about this the right way? Is there a simpler method that I have overlooked that can provide the same results?
I have tried using list boxes, but I cannot get the list box to update correctly to the underlying table, nor to update correctly when moving from one contact to the next. The simplest method I can think of would be to use yes/no boxes for each list, but I have no idea what the final lists of resources will be, so adding a check box to the table everytime a new resource is requested does not seem reasonable.
My code for these lists and actions is basically creating 4 temp queries (addClass, delClass, addJobName, and delJobName), and deleting them in the 'after update' event of the respective list. The buttons on the subform for add or delete copy to the ID# from the selected list in the on click event. If posting the code will be helpful, I can do that.
Any help would be appreciated. Thanks!
 
Hallo,

That's quite a wordy explanation :)
One way would be to have a table of Job Classes, tblJobClasses and a table of Job Names linked to those classes, ie.
tblJobClasses:
strJobClass

and tblJobNames:
strJobClass
strJobName

There would be a link (with Ref. Int.) between the two strJobClass fields.

I'd then make the form have two list boxes, lstJobClass and lstJobName.
lstJobClass would have a rowsource of:
SELECT strJobClass from tblJobClasses ORDER BY strJobClass

In the AfterUpdate (or is it OnChange?) of lstJobClass put:
me!lstJobNames.RowSource="SELECT strJobName FROM tblJobNames WHERE strJobClass='" & me!lstJobClass & "'"

In the Form_Open event, set put:
me!lstJobClass = me!lstJobClass.Column(0)
lstJobName_AfterUpdate
to set up the lists initially.

I appreciate that this may not exactly answer your question, but it is a solid way to link two lists.

- Frink
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top