This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!
LastDLLError Property Example
When pasted into a
UserForm module, the following code causes an attempt to call a DLL function. The call fails because the argument that is passed in (a null pointer) generates an error, and in any event, SQL can’t be cancelled if it isn’t running. The code following the call checks the return of the call, and then prints at the
LastDLLError property of the
Err object to reveal the error code. On systems without DLLs,
LastDLLError always returns zero.
Private Declare Function SQLCancel Lib "ODBC32.dll" _
(ByVal hstmt As Long) As Integer
Private Sub UserForm_Click()
Dim RetVal
' Call with invalid argument.
RetVal = SQLCancel(myhandle&)
' Check for SQL error code.
If RetVal = -2 Then
'Display the information code.
MsgBox "Error code is :" & Err.LastDllError
End If
End Sub