A family of Microsoft relational database management systems designed for ease of use.
The instruction
End
will end all code execution and reset all variables.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a macro that does steps 1-3, step 4 is RunCode GetStuffAndDoStuff()
Steps 5 and 6 are more macro commands.
If there is an error in step 4, the part that is VBA code, on error exit function just continues the flow with steps 5 and 6.
How do I stop all macros if step 4 errors so that steps 5 and 6 don't execute?
Something like on error DoCmd.StopAllMacros
Thanks in advance.
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
The instruction
End
will end all code execution and reset all variables.
Try this:
Public Function Lib_Forms() As Boolean
Dim Filename As String
Dim DestName As String
Dim OrigPath As String
Dim OrigFile As String
Dim DestFile As String
On Local Error GoTo Out
OrigPath = "L:\legalper\lib\forms"
OrigFile = Form_DA.LibForm.Text
If Forms!DA!DA = 2 Then
DestFile = "merge_li.docx"
ElseIf Forms!DA!DA = 1 Then
DestFile = "merge_li.frm"
End If
DestName = Tmppath & DestFile
Filename = OrigPath & OrigFile
FileCopy Filename, DestName
Lib_Forms = True
Exit Function
Out:
'When the document does not exist in the library:
MsgBox "Form does not exist in the Library. We are sorry but database will close now.", , _
"So Sorry..."
End Function
In the macro that calls the Lib_Forms function, use Lib_Forms()=False as Condition for the StopAllMacros action.
Public Function Lib_Forms() As Boolean
Dim Filename As String
Dim DestName As String
Dim OrigPath As String
Dim OrigFile As String
On Local Error GoTo Out
OrigPath = "L:\legalper\lib\forms"
OrigFile = Form_DA.LibForm.Text
Dim DestFile As String
If Forms!DA!DA = 2 Then
DestFile = "merge_li.docx"
Else
If Forms!DA!DA = 1 Then
DestFile = "merge_li.frm"
End If
End If
DestName = Tmppath & DestFile
Filename = OrigPath & OrigFile
FileCopy Filename, DestName
Exit Function
Out:
‘When the document does not exist in the library:
MsgBox "Form does not exist in the Library. We are sorry but database will close now.", , "So Sorry..."
‘This is where I put the END statement, but I see the macros of steps 5 and 6 continuing here and
‘since it’s an mde file, the macros error out and close the .mde file
End Function
Could you post the code for step 4?
Sorry, I had already tried that before posting. It isn't working. I can see the "post vba" macros running,