A family of Microsoft relational database management systems designed for ease of use.
I think the #error in this case is normal.
All code is stopped when it hits the Stop in the code. If I add a Wait to your code so that the query can finish processing before the stop, there is no #error returned.
Private Sub Command0_Click()
DoCmd.OpenQuery "Query1"
Wait 1
Stop
End Sub
Add the function to a module.
Public Function Wait(intPauseSeconds As Integer) As Boolean
On Error GoTo Err_Proc
Dim sngStart As Single
' intPauseSeconds duration.
sngStart = Timer ' Set start time.
Do While Timer < sngStart + intPauseSeconds
DoEvents ' Yield to other processes.
Loop
Wait = True
Exit_Proc:
Exit Function
Err_Proc:
MsgBox Err.Number & " " & Err.Description, vbOKOnly + vbCritical, "Error"
Wait = False
Resume Exit_Proc
End Function