I have an Access db which has several tables linked. Now I'ld like to execute SET IDENTITY_INSERT ON/OFF on those tables. I googled and found things like this
Private mDb As Database
Public Sub SetIdentityInsert(strTableName As String, strOnorOff As String)
Dim qdf As QueryDef
Dim strSQL As String
On Error GoTo Proc_Err
Set qdf = mDb.QueryDefs("qryIDENTITY_INSERT")
strSQL = "SET IDENTITY_INSERT " & strTableName & " " & strOnorOff
qdf.SQL = strSQL
qdf.Execute
Proc_Exit:
On Error Resume Next
Set qdf = Nothing
Exit Sub
Proc_Err:
Resume Proc_Exit
Resume
End Sub
However, if I do this
Dim qdf As QueryDef
Set qdf = CurrentDb.QueryDefs("Passthru")
I complains that the passed string has to be one of DELETE, INSERT, SELECT, PROCEDURE or UPDATE.
I'm pretty sure this is possible somehow. Here the author pastes example code calling a Sub ExecutePassThru, but the code for it is absent.