Select Only Some Records

L

LindaC

Several users from different departments will be entering records. Once they
have selected their department in an input form I would like them to be able
to only select descriptions for their department from a drop down. How do I
set this up in my table.
tblDepartment (Record Finance)
tblMajorDescriptions (Records Budget, Minutes, Drug Submission)

For example if they select Finance in the Input Screen I want them only to
see the records Budget and Minutes. Drug Submission belongs to another
department. Thanks.
 
K

Ken Sheridan

The way this is commonly done is by means of correlated combo boxes, so that
having made a selection in one combo box the available items in the second
combo box are restricted on the basis of the selection made in the first.

You'd start with a combo box of departments, cboDepartnents say, which lists
all departments by means of a RowSource such as:

SELECT Department
FROM tblDepartments
ORDER BY Department;

The second combo box of descriptions, cboMajorDescriptions say, would be
correlated with the first by referencing it in its RowSource, e.g.

SELECT MajorDescription
FROM tblMajorDescriptions
WHERE Department = Form!cboDepartments
ORDER BY MajorDescription;

The tblMajorDescriptions table must have a foreign key Department column of
course.

Note that because both controls are on the same form you can use the Form
property to refer to the form rather than having to fully reference it by
name in the above SQL statement.

To get the second combo box to restrict its list to those descriptions
applicable to the selected department you need to requery it in the
AfterUpdate event procedure of cboDepartments with:

Me.cboMajorDescriptions.Requery

While the above will work it does mean that there is some redundancy in the
table underlying the form. As the department is inferred by the description
the inclusion of a Department column in the table is redundant. This leaves
it open to possible update anomalies, which is exactly what the use of the
correlated combo boxes is attempting to prevent. There is still the
theoretical possibility of the table being incorrectly updated in some other
way however, so the integrity of the data is still open to possible
compromise. You'll find a demo at the following link of how to eliminate the
redundancy but still be able to select a department first then a description.
It uses different types of data (the local administrative areas in my part
of the world) and there are three levels to the hierarchy rather than two,
but the principle is just the same:


http://community.netscape.com/n/pfx...yMessages&tsn=1&tid=23626&webtag=ws-msdevapps



Ken Sheridan
Stafford, England
 
L

LindaC

Thanks for the information, but this is so above me. I thought Access would
easily handle my question as I would have thought others would require this
too. Perhaps it is in my setup that is the problem.
 
S

Scott McDaniel

Thanks for the information, but this is so above me. I thought Access would
easily handle my question as I would have thought others would require this
too. Perhaps it is in my setup that is the problem.

Access won't handle this for you natively, at least not with combos or listboxes ... you'd need to delimit them as Ken
has shown. Access can do this to some degree with subforms, but that's definitely not what you'd want in your case.
You're basically looking for "cacading combos". The links below may help you to understand this better:

http://www.thescripts.com/forum/thread605958.html
http://www.candace-tripp.com/pages/access_downloads.aspx (see the Cascading Combo Boxes Database download)

 
S

Steve

You need the following tables:
TblDepartment
DepartmentID
DepartmentName

TblMajorDescription
MajorDescriptionID
MajorDescription

TblRecord
RecordID
DepartmentID
MajorDescriptionID
....Your Record ....

You need a form/subform to display your records. The main form needs to be
based on TblDepartment and the subform needs to be based on TblRecord. Be
sure to set the LinkMaster and Linkchild properties to DepartmentID. If you
don';t have too many departments, you can use the navigation buttons at the
bottom left to go to the deoartment you want. Otherwise you need a way in
the main form to select the department you want and go to that department.
As soon as you go to any department in the main form, only the records for
that department will be displayed in the subform. This is a simple Access
setup! In fact, Access has a form wizard that can create your form/subform.
No cascading comboboxes are needed!!

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top