Note that there are some explanatory texts on larger screens.

plurals
  1. PODAO .Execute method fails in Access mde
    primarykey
    data
    text
    <p>First off, I'm using Access 2000 and DAO. I have code that executes a simple INSERT INTO query that I call using db.Execute. This code works fine inside an mdb. However, if I compile into an mde then I get </p> <blockquote> <p>error 5 - Invalid procedure call or argument </p> </blockquote> <p>on this line and the record does not get inserted. However, if I change from db.Execute to DoCmd.RunSQL using the exact same SQL statement the record is inserted with no problems. Does anyone know why the DAO Execute method of the DAO database object would suddenly stop working once I compile into an MDE? </p> <p><em>Note</em>: I only get the error if I specify the dbFailOnError option of the .Execute method. If I leave that option off, I get no error but the record is still not inserted.</p> <p>EDIT:<br> This line fails in the MDE (<em>but works fine in the MDB</em>):</p> <pre><code>App.db.Execute InsertSQL, dbFailOnError </code></pre> <p>From the immediate window with a breakpoint on the above line of code:</p> <pre><code>?InsertSQL INSERT INTO Changes (PropertyID, FieldID, [Which], [When], [Before], Reason, ReportChange) VALUES (1, 2, "M", #2/19/2010 4:51:44 PM#, "Suite 2; 430 W KING ST; ABBOTTSTOWN, PA 17301-9771", "Per Owner", True) </code></pre> <p>(I have an entire class module dedicated to building and executing SQL statements, so it's not really practical to show exactly how I built the InsertSQL string variable. However, I really don't think that is relevant.)</p> <p>This line works everywhere:</p> <pre><code>DoCmd.RunSQL InsertSQL </code></pre> <p>EDIT: App.db definition (note that there is no reference in my project to ADO, only DAO):</p> <pre><code>Public App As New clsApp </code></pre> <p>clsApp class module (relevant lines only):</p> <pre><code>Private m_objDB As Database Public Property Get db() As Database Set db = m_objDB End Property Private Sub Class_Initialize() Set m_objDB = CurrentDb End Sub Private Sub Class_Terminate() Set m_objDB = Nothing End Sub </code></pre> <p>If you are curious, I use App.db rather than CurrentDB for two main reasons: 1) slight performance gain by not having to call the CurrentDB function repeatedly (call it once then just refer to the object it returns) and 2) properties of the database object like .RecordsAffected always return relevant information. Plus, it's faster to type. And I'm a programmer, so I'm inherently lazy.</p> <p>EDIT: Let me first apologize to those who have been following this thread and trying to help me. It seems I may have left out the critical details of my problem. The App.db.Execute call takes place inside a class module (clsSQL) and it references a global variable named App which is itself an instance of a different class module (clsApp). I'm guessing the problem is that I am referring to an instance of a class module from within another class module. Can anyone confirm if calling one class module from within another is something that is supported by MDBs and not MDEs? [<em>It is not an issue. I was way over-thinking this. See my answer for the full story.</em>]</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload