Solved

Executing SQL on a Form's Recordset

Posted on 2011-09-14
4
355 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 500 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add records to a form to a table 11 39
Access 2016 - query 23 59
Top 1 of each supplier 55 55
IIF help, YN field 7 22
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

776 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