sort options unavailable for column of data in query

R

rlwilliams9

I have developed a database of incidents. I have created a query of incident
types. the types of incident are in a lookup that allows multiple values.
When the query is in datasheeet view the sort options for the column
containing the incident type data are grayed out. Consequently the query is
useless.

I need to sort by incident type from highest count to lowest for all. I
then need a report sorting them from greatest occurrence to least, and anoter
report of the top five.
 
D

Dale Fye

You have made a couple of what I would call (personal opinion) major errors.

1. You have used a configured your table with a "lookup" column. I
personally believe this was a mistake made by Microsoft to make it easier
for newbies to develop databases. Unfortunately, what it really does is
hide the true value that is stored in the table from the user and allows
them to see a value that is not really there.

2. You used the LookupWizard to create your field, allowing you to select
the "Allow multiple values" checkbox. This is another one of those mistakes
I think Microsoft made. One of the key principles of database development
is normalization, and storing more than one piece of information in a single
field violates the #1 rule of table development. Although it looks like you
have multiple values in a single field, what MS actually does is creates a
hidden table that has a one-to-many relationship with your main table. The
down side of this is that you have no control over this hidden table, and
really cannot query it the way you normally would.

3. You are using the datasheet view for entering data. Again, this is
personal opinion, but if you really want a professional looking database
application, you will minimize the use of the datasheet view. Instead,
create a subform on your main form where you allow the user to select the
incident type (or types) that apply to an incident.

As an example, you might have the following three tables (tbl_Incidents,
tbl_Lookup_Incident_Types, tbl_Incident_Types) with structures that look
like:

tbl_Incidents
Incident_ID - Autonumber (PK)
Driver_ID - Number
Incident_DT - Date/Time
....

tbl_lookup_Incident_Types
Incident_Type_ID
Incident_Type_Title
Incident_Type_Description
Sort_Order
(I like to include a Sort_Order field in all my lookup tables so that I can
return them in the order I want)

tbl_Incident_Types
Incident_ID
Incident_Type_ID
'In this table, you create a composite key on both fields, and make it
unique, so you cannot have more than one copy of the same Incident_Type_ID
matched against a particular Incident_ID.

Your main form would contain the basic Incident information.
The subform would contain the IncidentID (related to the Incident_ID on the
main form), and a combo box which contains the values in
tbl_lookup_Incident_Types. Then, when the user creates an incident, they
simply select the appropriate incident type(s) from the combo box in the
subform.

HTH
Dale
 
R

rlwilliams9

I modified the query per you instructions and get this message:
"The multi-valued field cannot be used in an ORDER BY clause."
How do I fix this?
 

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