I'm using the Balloon feature of the Assistant to prompt the user to select how to proceed with a process. The problem is that I want to exit sub if a problem occurs in the callback. I will paste the code below, but essentially here is what going on: The record begins as status=1. The user clicks cmdProcess. All relavent fields are checked for data, if not exit sub. If all fields contain data, the assistant appears and prompts the user to specify the output of a report (email,fax,preview,print). Only after the selection is made and the report is output do I want status to be bumped to 2.
If an error occurs during output or if the user cancels output I want to exit sub before the status if bumped up.
[This message has been edited by charityg (edited 05-31-2001).]
[This message has been edited by charityg (edited 05-31-2001).]
If an error occurs during output or if the user cancels output I want to exit sub before the status if bumped up.
Code:
Private Sub cmdProcess_Click()
Dim ctl As Control, subfrm As SubForm
Dim strStatus As String
Dim strctlvalue As String
Dim strctltext As String
Dim offBalloon As Office.Balloon
strStatus = Status
Me!Customer.SetFocus
For Each ctl In Me.Controls
If (ctl.Tag = strStatus) And ctl.Visible = True Then
If ctl.ControlType <> acSubform Then
strctlvalue = Nz(ctl.Value, 0)
If strctlvalue = "0" Then
ctl.SetFocus
MsgBox "You must enter all required information before processing."
Exit Sub
End If
End If
End If
Next ctl
Select Case Status
Case 1, 4
Set subfrm = Me!sec1sub
Case 2
Set subfrm = Me!sec2sub
Case 3
Set subfrm = Me!sec3sub
Case 5, 6
Set subfrm = Me!sec4sub
Case 7
Set subfrm = Me!sec5sub
End Select
For Each ctl In subfrm.Controls
If ctl.Tag = strStatus Then
strctltext = ctl.Name
MsgBox ctl.Name
strctlvalue = Nz(ctl.Value, 0)
If strctlvalue = "0" Then
subfrm.SetFocus
ctl.SetFocus
MsgBox "You must enter all required information before processing."
Exit Sub
End If
End If
Next ctl
Select Case Status
Case 1
Set offBalloon = Application.Assistant.NewBalloon
With offBalloon
' Show the Office Assistant.
.Parent.Visible = True
' Set the heading and text of the balloon.
.Heading = "Processing Options"
.Text = "How would you like to process the Customer's RGA form?"
' Make the balloon modeless.
.Mode = msoModeModeless
' Display the Cancel Button.
.Button = msoButtonSetCancel
.Labels(1).Text = "Preview"
.Labels(2).Text = "Print"
.Labels(3).Text = "Fax"
.Labels(4).Text = "Email"
flgCancel = False
.Callback = "WhichButton"
.Show
End With
End Select
If flgCancel = True Then Exit Sub
Status = Status + 1
end sub
Public Sub WhichButton(bln As Balloon, iBtn As Long, iPriv As Long)
On Error GoTo call_error
Dim strdocname As String
strdocname = "report1"
bln.Close
Assistant.Visible = False
Select Case iBtn
Case 1
DoCmd.OpenReport strdocname, acPreview
Case 2
DoCmd.OpenReport strdocname, acNormal
Case 3
DoCmd.OpenReport strdocname, acViewPreview
Case 4
DoCmd.SendObject acSendReport, strdocname, , , , , , , True
Case msoBalloonButtonCancel
call_error:
flgCancel = True
Exit Sub
End Select
End Sub
[This message has been edited by charityg (edited 05-31-2001).]
[This message has been edited by charityg (edited 05-31-2001).]