Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,564
- Office Version
- 365
- 2016
- Platform
- Windows
At a point in my userform initialization, I call a routine that checks for missing information that is critical to the userform initialization continuing.
uf_create_wo2 initialization
missing_rental_info
The above procedure compiles a list of missing unique rental numbers from the source data. As long as there are missing rental numbers, userform uf_create_wo2 must not continue. This procedure allows the user to access another module (which can be used outside of this calling to enter information outside of error checking) to enter information pertaining to the missing rentals by calling userform group_1 ... a userform whose purpose is to process rental number information.
The group_1 initialization code uses the information compiled in the procedure above. There is an "EXIT" commandbutton (exit1) in userform group_1 allowing users to exit the process. If the user chooses to exit while there is still unprocessed rental information, the user is prompted to confirm the action of quitting prematurely.
exit1
If "YES", it is hoped to close any further code, returning the user to the main launch worksheet ("DYNAMIC"). In the most part it's doing so with the code I've experimented with thus far.
The issue ... the code eventually returns to the original userform uf_create_wo2 initialization in the line in green above. This is not good, as all kinds of problems related to missing information results.
What do I need to do to exit everything completely when the user chooses yes to abandoning critical information entry and preventing userform initialization from resuming?
uf_create_wo2 initialization
Rich (BB code):
Private Sub UserForm_Initialize()
... some code
missing_rental_info ws_rd, norec 'lng_miss_rtl '[module 21]
For i = 2 To norec + 1
... some code
End Sub
missing_rental_info
Rich (BB code):
Sub missing_rental_info(ByVal ws_rd As Worksheet, ByVal norec As Long) ', ByVal lng_miss_rtl As Long
Dim i As Double
Dim ui2 As VbMsgBoxResult
Dim ws_core As Worksheet
Dim ws_vh As Worksheet
Dim fn As String
Dim mr_cnt As Integer
fn = Workbooks("Sports15b.xlsm").Worksheets("VAR_HOLD").Range("B4")
MsgBox fn
Set ws_core = Workbooks(fn).Worksheets("CORE")
Set ws_vh = Workbooks("Sports15b.xlsm").Worksheets("VAR_HOLD")
With ws_vh
.Range("J5") = 0
.Range("K5:K105").Cells.ClearContents
End With
With ws_core
lng_miss_rtl = 0
For i = 2 To norec
If IsError(Application.Match(.Range("C" & i), ws_rd.Range("A:A"), 0)) Then
mr_cnt = mr_cnt + 1
With ws_vh
.Range("J5") = mr_cnt
.Range("K" & mr_cnt + 4) = ws_core.Range("C" & i).Value
End With
End If
Next i
End With
If mr_cnt > 0 Then
ui2 = MsgBox(mr_cnt & " record(s) were encountered that are not in the rental database." & Chr(13) & Chr(13) & "To proceed, you must submit this missing rental information to the database." _
& Chr(13) & Chr(13) & "Do you wish to do this now?", vbCritical + vbYesNo, "CRITICAL ERROR")
If ui2 = vbYes Then
Workbooks(fn).Close False
group_1.Show
Else
Workbooks(fn).Close False
Worksheets("DYNAMIC").Activate
Unload uf_create_wo2
End If
End If
End Sub
The above procedure compiles a list of missing unique rental numbers from the source data. As long as there are missing rental numbers, userform uf_create_wo2 must not continue. This procedure allows the user to access another module (which can be used outside of this calling to enter information outside of error checking) to enter information pertaining to the missing rentals by calling userform group_1 ... a userform whose purpose is to process rental number information.
The group_1 initialization code uses the information compiled in the procedure above. There is an "EXIT" commandbutton (exit1) in userform group_1 allowing users to exit the process. If the user chooses to exit while there is still unprocessed rental information, the user is prompted to confirm the action of quitting prematurely.
exit1
Rich (BB code):
Private Sub exit1_Click()
Dim ui2 As VbMsgBoxResult
Dim ws_vh As Worksheet
Set ws_vh = Workbooks("Sports15b.xlsm").Worksheets("VAR_HOLD")
If ws_vh.Range("J5") > 0 Then
ui2 = MsgBox("You still have outstanding missing rental information." & Chr(13) & "Are you sure you wish to exit?", vbInformation + vbYesNo, "OUTSTANDING RENTAL INFORMATION")
If ui2 = vbYes Then
Unload uf_create_wo2
Worksheets("DYNAMIC").Activate
Unload Me
Exit Sub
Else
Exit Sub
End If
Else
Unload Me
End If
End Sub
If "YES", it is hoped to close any further code, returning the user to the main launch worksheet ("DYNAMIC"). In the most part it's doing so with the code I've experimented with thus far.
The issue ... the code eventually returns to the original userform uf_create_wo2 initialization in the line in green above. This is not good, as all kinds of problems related to missing information results.
What do I need to do to exit everything completely when the user chooses yes to abandoning critical information entry and preventing userform initialization from resuming?