Hi,
I am writing/running VBA code through MS Access 2007.
I have a loop in the master sub. When a condition is met in its nested sub, I want the loop to stop and exit the procedure.
Just wondering: what's kind of statement or command I can use for this purpose?
The structure of the code is like:
Private Sub exp2exall_Click()
......
Do Until rstStores.EOF
.....
GenerateReport strReportPath, Trim(rstStores![Nam])
rstStores.MoveNext
Loop
End If
.....
End Sub
Private Sub GenerateReport(ReportPath As String, Nam As String)
...
' Deal with the issue that cannot find the template file
If Dir(ReportPath & "\Template File.xlsx ") = "" Then
MsgBox "[Template File.xlsx] cannot be found under this folder. Please try a different path."
Kill ReportPath & "\Temp.xls"
{End/exit sub exp2exall_Click()}
Exit Sub
Else
' Open a template report to hold the exported info from the temporary Excel sheet
Set wkbDest = xl.Workbooks.Open(ReportPath & "\Template File.xlsx ")
End If
...
End Sub
How to write the code for {End/exit sub exp2exall_Click()}?
So, if the template file can't be found, the sub exp2exall_Click() and GenerateReport(ReportPath As String, Nam As String) will be ended.
Thank you in advance.