"Editing records in query" problem

nadoona

Registered User.
Local time
Tomorrow, 00:35
Joined
Jul 17, 2004
Messages
11
Hi,
I have a query based on two tables and I have a problem in editing records on it.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Here is its SQL:

SELECT OrdersTable.OrderNo, CompaniesTable.CompanyName, CompaniesTable.CustomerName, OrdersTable.Date, OrdersTable.Cancelled, OrdersTable.Paid, OrdersTable.Comments
FROM CompaniesTable INNER JOIN OrdersTable ON CompaniesTable.CompanyID = OrdersTable.CompanyID
WHERE (((CompaniesTable.CompanyID) Like [Forms]![InvoiceSearchByCompany]![Combo0]))
GROUP BY OrdersTable.OrderNo, CompaniesTable.CompanyName, CompaniesTable.CustomerName, OrdersTable.Date, OrdersTable.Cancelled, OrdersTable.Paid, OrdersTable.Comments, OrdersTable.OrderType
HAVING (((OrdersTable.Paid) Like [Forms]![InvoiceSearchByCompany]![Combo16]) AND ((OrdersTable.OrderType)="Out"));
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I don't know what's the problem that prevents me to edit records using the query. I hope anyone knows that problem.

I've also attached a picture that illustrates the relationships of my database. I don't know if it will help or not.

Thanks a lot for reading this.
 

Attachments

  • Relationships.JPG
    Relationships.JPG
    22.7 KB · Views: 123
Any query using a group by is READ ONLY

Greetz
 
Thanks a lot "namliam". I eleminated the "group by" and I can edit the records now.
Thanks again 4 ur help
 
You have other problems with this query. You should NEVER use like when you mean =. They are NOT interchangable. Like forces the database engine to read EVERY row of a table rather than optimizing a query. You also need to get rid of the Having clause and incorporate it into the Where clause.

SELECT OrdersTable.OrderNo, CompaniesTable.CompanyName, CompaniesTable.CustomerName, OrdersTable.Date, OrdersTable.Cancelled, OrdersTable.Paid, OrdersTable.Comments
FROM CompaniesTable INNER JOIN OrdersTable ON CompaniesTable.CompanyID = OrdersTable.CompanyID
WHERE (((CompaniesTable.CompanyID) = [Forms]![InvoiceSearchByCompany]![Combo0]))
AND (((OrdersTable.Paid) = [Forms]![InvoiceSearchByCompany]![Combo16]) AND ((OrdersTable.OrderType)="Out"));
 

Users who are viewing this thread

Back
Top Bottom