Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Executing SQL on a Form's Recordset

Posted on 2011-09-14
4
Medium Priority
?
389 Views
Last Modified: 2013-11-28
I have a form with a procedure that updates all records in the data set.  Using SQL is the most efficient way to do this (rather than looping through the form's recordset).  But if I use CurrentDb.Execute strSQL, the form barks at me about another user altering the recordset.  Is there a way to run the SQL within the scope of the form?  Perhaps a DAO or ADO command?

Mike
0
Comment
Question by:shacho
  • 2
  • 2
4 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 36540280
Mike,

Try saving the data on the form immediately before the CurrentDb.Execute strSQL statement.

To do this, you can use the following:
    docmd.RunCommand acCmdSaveRecord


0
 

Author Comment

by:shacho
ID: 36540283
Nice.  I think I see why that works.  Should have considered that.  Thanks a lot!

Mike
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36540295
That is the solution for a lot of similar issues... basically you want any data that is in the process of being edited to either be "undone" or fully committed to the table before beginning any seperate editing or saving process.  Otherwise, even if it is just the actions of one user, it has the net effect of multiple people stepping on each other's toes.
0
 

Author Comment

by:shacho
ID: 36540300
Indeed.  Makes sense.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question