I'm trying to do an append from one database (source) to a second database (destination) where destination has user level security.
It correctly logs in, via the below text switches, but freezes at the "DoCmd.RunSQL strSQL" command and reports a runtime 3033 about an unauthorized user. Ideally, I'd want to only use a full-data-user ID for the below query, but read on other threads that the below might be considered to be a Modify Design task because the SQL is compiled at runtime. Have tried login/password for an admin, and I don't understand why the security settings still prevent it from running.
Code:
Function append_external()
Dim strPath As String
Dim strAccDir As String
Dim strAccPath As String
Dim strSQL As String
strAccDir = SysCmd(acSysCmdAccessDir)
strAccPath = strAccDir & "MSACCESS.EXE"
strPath = Chr(34) & strAccPath & Chr(34) & " " & Chr(34) & "<path to destination db>" & Chr(34) & " " & "/wrkgrp " & Chr(34) & "<path to destination db mdw file>" & Chr(34) & " " & "/User " & Chr(34) & "<login>" & Chr(34) & " " & "/Pwd " & Chr(34) & "<password>" & Chr(34)
Shell strPath, vbMaximizedFocus
strSQL = "INSERT INTO [;DATABASE=<path to destination db>].Table1 SELECT * FROM [;DATABASE=<path from source db>].Table1;"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
End Function