| ACC97: IPF When Using Execute Method with dbFailOnErrorID: Q180348 
 | 
Advanced: Requires expert coding, interoperability, and multiuser skills.
When you run a Visual Basic for Applications procedure that uses the
Execute method to update data in a Microsoft SQL Server ODBC data source,
you may receive the following error message.
An application error has occurred and an application error log is being generated.
MSACCESS.exe
Exception: access violation (0xc0000005)
This program has performed an illegal operation and will be shut down.
When you click Details, you see the following message:
MSACCESS caused an invalid page fault in module KERNEL32.DLL.
You receive this error message when all of the following conditions are
true:
Create a temporary SQL pass-through query in your Visual Basic for
Applications procedure. Concatenate the text string with which you want to
update the field into the SQL statement; set the SQL property of the
QueryDef to the SQL statement. You can then use the Execute method of the
QueryDef with the constant dbFailOnError. The following example
demonstrates how to implement the procedure:
      Function PassThruUpdate(strUpdateData As String)
         Dim db As Database
         Dim qd As QueryDef
         Dim strSQLString As String
         On Error GoTo Err_PassThruUpdate
         Set db = CurrentDb
         Set qd = db.CreateQueryDef("")
         ' Modify the connect string in the following line
         ' to reflect the ODBC data source you are using.
         qd.Connect = "ODBC;DSN=sqltest;UID=sa;PWD=;DATABASE=pubs"
         strSQLString = "UPDATE tbltoSQL SET StringTest = '"
         strSQLString = strSQLString & strUpdateData
         strSQLString = strSQLString & "' WHERE id = 'a'"
         qd.ReturnsRecords = False
         qd.SQL = strSQLString
         qd.Execute dbFailOnError
         db.Close
      Exit_PassThruUpdate:
         Exit Function
      Err_PassThruUpdate:
         MsgBox CStr(Err) & " " & Err.Description
         Resume Exit_PassThruUpdate
      End Function 
       Table: tblToSQL
       ----------------------
       Field Name: ID
          Data Type: Text
          Field Size: 2
       Field Name: StringTest
          Data Type: Text
          Field Size: 100
       Table Properties: tblToSQL
       --------------------------
       PrimaryKey: ID 
       ID  FullName
       --  --------
       a   aaa
       b   bbb 
       Function TestExecute(intUpdateLength As Integer)
          Dim db As Database
          Dim strSQLString As String
          Dim strUpdateString As String
          strUpdateString = String(intUpdateLength, "X")
          strSQLString = "UPDATE dbo_tblToSQL SET StringTest = '" & _
             strUpdateString
          strSQLString = strSQLString & "' WHERE id = 'a';"
          Set db = CurrentDb
          db.Execute strSQLString, dbFailOnError
          db.Close
       End Function For more information about the Execute method, search the Help Index for "Execute method," and then display the "Execute Method (DAO)" topic.
Additional query words: Watson
Keywords          : EvnGpf MdlGnrl MdlProb 
Version           : WINDOWS:97
Platform          : WINDOWS 
Issue type        : kbbug Last Reviewed: April 19, 1999