We help IT Professionals succeed at work.

Select Query By design Can Not Convert To Update Query !

Issa S.
Issa S. asked
on
112 Views
Last Modified: 2018-01-17
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

Scott McDaniel (EE MVE )Infotrakker Software
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
Post the SQL of the query.
Dale FyeOwner, Dev-Soln LLC
CERTIFIED EXPERT
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;
Dale FyeOwner, Dev-Soln LLC
CERTIFIED EXPERT
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
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2010
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

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
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2010

Commented:
glad to help.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions