Can't edit a Group by Query (1 Viewer)

Tina49

Registered User.
Local time
Today, 02:56
Joined
Sep 29, 2011
Messages
34
I have a query where I group by EmpID, so duplicates do not show up. In this query I have two fields with no data. These fields are to be filled in after the query is run in a form. However, these fields are not editable due to the group by feature. Any work arounds for this? I tried two unbound fields, which does allow me to type, but doesn't save the changes once I click out of the field. The field then reverts back to blank. Thanks in advance for any help you can give.
 

jdraw

Super Moderator
Staff member
Local time
Today, 05:56
Joined
Jan 23, 2006
Messages
15,379
You could build a form bound to your table and use it to enter/edit your record.
Since it's bound, the new data should be saved when you move to another record.

I'm not sure about your duplicate prevention explanation -- if it's important please tell us more. Perhaps your query joins Employees with Hobbies or something in a 1:m relationship??? and results in duplicates???

You may be able to create a form/subform set up -depending on the data and how the tables are related. Real question is what data is missing and to what entity/table does it apply?
 
Last edited:

Tina49

Registered User.
Local time
Today, 02:56
Joined
Sep 29, 2011
Messages
34
The duplicates occur when an employee is in more than one department. One employee to many departments. I am creating a Emergency Responders list and I only want each full time employee to appear once. Therefore my query is grouped by EmpID. The query pulls from two tables.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:56
Joined
Feb 19, 2002
Messages
43,293
If department is not critical to the query, don't join to the other table. When working with a form, use a main form for the employee information and a subform to show the departments. Proper use of forms and queries will eliminate the "duplication" issue.
 

Tina49

Registered User.
Local time
Today, 02:56
Joined
Sep 29, 2011
Messages
34
It is not that department is critical to the query, it is because of department that I have employee duplicate entries. The data is duplicated and I need to show the employee only once for this form. Thus the group by in the query.
 

jdraw

Super Moderator
Staff member
Local time
Today, 05:56
Joined
Jan 23, 2006
Messages
15,379
If you have 1 employee and that employee is "in" more than 1 department. As long as you include Employee and Department tables in your query, and ask for employee and department you will see that employee in each department he/she is "in".

Suppose you had a query that asked which employee is the "Emergency Responder" for each department (and John Doe is your Employee who is in more than 1 department)

Dept 1 --John Doe
Dept 2 --Sue Schmidt
Dept 3 --Joe Blow
Dept 4 --John Doe
Dept 5 --Patty Kake

It isn't that John Doe is duplicated, the reality is he is the employee that has been designated as Emergency Responder for Dept 1 and also for Dept 4. And the query asks for Dept and Employee.

Now if you asked, What are the Distinct Names of Emergency Responders (no department reference) you would only see John Doe once.

Note also, a duplicate in a query response, requires that there all fields in the response have the same value. Said differently, if you have a duplicate, you would have 2 rows returned and corresponding fields in each row would have the same value.

In your case
Dept 1 John Doe is NOT a duplicate of
Dept 4 John Doe.

Duplicate would be
Dept 1 John Doe
Dept 1 John Doe
or
Dept 4 John Doe
Dept 4 John Doe
 

Tina49

Registered User.
Local time
Today, 02:56
Joined
Sep 29, 2011
Messages
34
Correct, the employee is not duplicated because it is a one to many relationship. However, my data that holds the EmpID is duplicated in the "data holding table". It is this table that I need to draw the query from.
 

jdraw

Super Moderator
Staff member
Local time
Today, 05:56
Joined
Jan 23, 2006
Messages
15,379
??? I don't understand. Are you saying you have Empid is duplicated in the Employee Table?? What is the "data holding table"?
How about showing us the SQL view of your query?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:56
Joined
Feb 19, 2002
Messages
43,293
Also please post a picture of your schema where we can see tables with column names and relationship lines.
 

Tina49

Registered User.
Local time
Today, 02:56
Joined
Sep 29, 2011
Messages
34
No, what I am saying is the EmpID is a primary key and only appears once. The department data table is a table that holds all the data. It is the many table without a primary key. Employee table to DeptData table is a one to many relationship.
 

jdraw

Super Moderator
Staff member
Local time
Today, 05:56
Joined
Jan 23, 2006
Messages
15,379
To establish a relationship, your 1: many, between Employee and Department, you would have a FK (foreign key) in the Department table to hold the value(foreign key) of the related Employee.The value of the EmployeeId (or whatever you have called the PK in the Employee table) is that value that would be stored.

Good luck.

http://en.wikipedia.org/wiki/Foreign_key
 
Last edited:

Users who are viewing this thread

Top Bottom