On Error Resume Next DoCmd.open a Failure = Err.Number = 0 On Error GoTo 0 If Failure = エラー番号 Then ' エラーが発生した場合の処理 Else ' 成功した場合の処理 End If