J
Janis
I have this module that runs when an option button is clicked on a user
form. There is a done and cancel button also.
It runs well, the only time it doesn't run is if the user opens the wrong
workbook. I noticed when this happens that Excel doesn't quit the form. It
might be fixed now but I thought I would put in "on error resume next"?
Basically if the first macro doesn't run correctly then the other two don't
need to run either. Should I just put the resume next enclosed in the
if/then or after every procedure?
Thanks,
--------macro----------
Sub optReformatDepts_Click()
If Fprocess1 = True And Fprocess2 = True Then
Fprocess3 = False
If optReformatDepts.Value = True Then
Call ReformatDepts.ColorDivHeaders
On Error Resume Next
Call ReformatDepts.StatusRowHeader
On Error Resume Next
Call ReformatDepts.HideXtraColumns
On Error Resume Next
Call ReformatDepts.ReportSetup
Fprocess3 = True
End If
Else
MsgBox "Please check for duplicates and save first."
End If
End Sub
--------whole user form-----------
Dim Fprocess1 As Boolean
Dim Fprocess2 As Boolean
Dim Fprocess3 As Boolean
Sub cmdCancel_Click()
If MsgBox("Are you sure you want to cancel?", _
vbYesNo + vbQuestion, _
"Cancel") = vbYes Then Unload Me
End Sub
Sub cmdOkay_Click()
If Fprocess1 = True And Fprocess2 = True And Fprocess3 = True Then
Unload Me
Else
MsgBox " All options must be completed before closing"
End If
End Sub
Sub optCkforDupes_Click()
Dim nResult As Long
Debug.Print frRptDate
Debug.Print toRptDate
Fprocess1 = False
If optCkforDupes.Value = True Then
nResult = MsgBox(prompt:="From: " & FrReptDate & vbNewLine & "To: " &
ToReptDate, Buttons:=bvOKCancel, Title:="report Date")
End If
If nResult = vbOK Then
Call createXLdb.CkforDupes
Fprocess1 = True
End If
End Sub
Sub optSaveIndesign_Click()
If Fprocess1 = True Then
Fprocess2 = False
If optSaveIndesign.Value = True Then
Call saveIndesign.saveIndesign
Fprocess2 = True
End If
Else
MsgBox "Please check for duplicates first."
End If
End Sub
Sub optReformatDepts_Click()
If Fprocess1 = True And Fprocess2 = True Then
Fprocess3 = False
If optReformatDepts.Value = True Then
Call ReformatDepts.ColorDivHeaders
On Error Resume Next
Call ReformatDepts.StatusRowHeader
On Error Resume Next
Call ReformatDepts.HideXtraColumns
On Error Resume Next
Call ReformatDepts.ReportSetup
Fprocess3 = True
End If
Else
MsgBox "Please check for duplicates and save first."
End If
End Sub
Private Sub UserForm_Click()
End Sub
form. There is a done and cancel button also.
It runs well, the only time it doesn't run is if the user opens the wrong
workbook. I noticed when this happens that Excel doesn't quit the form. It
might be fixed now but I thought I would put in "on error resume next"?
Basically if the first macro doesn't run correctly then the other two don't
need to run either. Should I just put the resume next enclosed in the
if/then or after every procedure?
Thanks,
--------macro----------
Sub optReformatDepts_Click()
If Fprocess1 = True And Fprocess2 = True Then
Fprocess3 = False
If optReformatDepts.Value = True Then
Call ReformatDepts.ColorDivHeaders
On Error Resume Next
Call ReformatDepts.StatusRowHeader
On Error Resume Next
Call ReformatDepts.HideXtraColumns
On Error Resume Next
Call ReformatDepts.ReportSetup
Fprocess3 = True
End If
Else
MsgBox "Please check for duplicates and save first."
End If
End Sub
--------whole user form-----------
Dim Fprocess1 As Boolean
Dim Fprocess2 As Boolean
Dim Fprocess3 As Boolean
Sub cmdCancel_Click()
If MsgBox("Are you sure you want to cancel?", _
vbYesNo + vbQuestion, _
"Cancel") = vbYes Then Unload Me
End Sub
Sub cmdOkay_Click()
If Fprocess1 = True And Fprocess2 = True And Fprocess3 = True Then
Unload Me
Else
MsgBox " All options must be completed before closing"
End If
End Sub
Sub optCkforDupes_Click()
Dim nResult As Long
Debug.Print frRptDate
Debug.Print toRptDate
Fprocess1 = False
If optCkforDupes.Value = True Then
nResult = MsgBox(prompt:="From: " & FrReptDate & vbNewLine & "To: " &
ToReptDate, Buttons:=bvOKCancel, Title:="report Date")
End If
If nResult = vbOK Then
Call createXLdb.CkforDupes
Fprocess1 = True
End If
End Sub
Sub optSaveIndesign_Click()
If Fprocess1 = True Then
Fprocess2 = False
If optSaveIndesign.Value = True Then
Call saveIndesign.saveIndesign
Fprocess2 = True
End If
Else
MsgBox "Please check for duplicates first."
End If
End Sub
Sub optReformatDepts_Click()
If Fprocess1 = True And Fprocess2 = True Then
Fprocess3 = False
If optReformatDepts.Value = True Then
Call ReformatDepts.ColorDivHeaders
On Error Resume Next
Call ReformatDepts.StatusRowHeader
On Error Resume Next
Call ReformatDepts.HideXtraColumns
On Error Resume Next
Call ReformatDepts.ReportSetup
Fprocess3 = True
End If
Else
MsgBox "Please check for duplicates and save first."
End If
End Sub
Private Sub UserForm_Click()
End Sub