Select Query By design Can Not Convert To Update Query !

Issa S.
Issa S. used Ask the Experts™
on
Select Query By design Can Not Convert To Update Query !

After I Designed my Select Query and checked it getting the required data, I tried to Convert it to become Update. First it did not ask me for the table to update, as normally should do. I tried to define the destination table fields, but it is not recognizing the destination table or its fields.
Upon saving, it clears every thing!

Any help will be highly appreciated.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2014

Commented:
Post the SQL of the query.
Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010

Commented:
Sounds like corruption.  Backup the database, then perform a compact and repair.

Author

Commented:
In Fact I did the Compact minutes before this thing started.
First time I face something like this.
Below is the select SQL for your kind inspection and advice. . . . Thanks.

SELECT collects.ID, collects.voucher, collects.dname, collects.cname, collects.payment, collects.usamount, collects.Date, collects.voucher, collects.sanad, collects.amount, collects.retvalue, collects.daccount, collects.caccount, collects.remarks, collects.chno, collects.chdate, collects.withdr, collects.withdrb, collects.branch, collects.nome, collects.salesm, collects.collection, collects.times, collects.chdate, collects.chdate
FROM [Get Old Cheque ID LAST One] INNER JOIN collects ON [Get Old Cheque ID LAST One].MaxOfID = collects.ID
ORDER BY collects.ID DESC;
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010

Commented:
Although I doubt it makes a difference here, "Date" is a reserved word.  I recommend that you make that field name more descriptive if you can (like you did with chDate).  If you cannot make that change, then I would strongly recommend that you wrap that field name in brackets:

collects.[Date]

What is it you are trying to update, something in Collects with something from your query [Get Old Cheque ID Last One]?  Generally a query will not be updateable if it includes any aggregates, and it looks like your query with the MaxID might do that.  

But you also made the comment:  "I tried to define the destination table fields" which implies that you are actually trying to append this data into another table, and there shouldn't be anything here preventing that.

Dale

Author

Commented:
Yes, you are right. I found that I used Grouping.

But how can you avoid using Grouping if you need to pick the last or the Max of FK and use it since it selects correctly and works well with Make, Append, Not Sure about CrossTab.

The easiest for me was to keep the current logic and use a buffer (Make) table that I delete on every entry. Then Make.

Thanks For your help.
Owner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010
Commented:
I generally have a local table in almost every one of my databases.  This table contains only two fields, a long integer field (TempID, indexed and unique) and a Yes/No field (IncludeThis).  I use this table for a variety of reasons, and this would be one of them.  Instead of simply creating the query that gets the MAX(ID) value for each customer or order, I delete all records from this temp table, run an append query to dump those MaxID values into that table, and because that table contains a unique TempID value, when you join it to your other table, it should be updateable.  

BTW, the [IncludeThis] field is immaterial to this discussion, but I use that to allow me to "select" items from this table and use that selection in a variety of ways.

Dale

Author

Commented:
Hi Dale,,,

Amazing.  That is also my way. In cases am not sure of something, I use a temp field with the ID key so don't miss the correct one. This is only spontaneous and for Updating immediately only since you can not rely on IDs changing with other operations like delete and add.

Thanks

Author

Commented:
Very Comprehensive.
Thanks a Lot Dale.
Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010

Commented:
glad to help.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial