Message Box Response...

Graham T

Registered User.
Local time
Today, 15:53
Joined
Mar 14, 2001
Messages
300
On my switchboard, for the Quit application command button I have the following code

Code:
If DCount("[tblJobOutcomes]![lngJobOutcome]", "[tblJobOutcomes]", "[tblJobOutcomes]![ysnSentByMailToStaff]=0") = 0 Then
Application.Quit
ElseIf DCount("[tblJobOutcomes]![lngJobOutcome]", "[tblJobOutcomes]", "[tblJobOutcomes]![ysnSentByMailToStaff]=0") >= 1 Then
MsgBox "You have " & DCount("[tblJobOutcomes]![lngJobOutcome]", "[tblJobOutcomes]", "[tblJobOutcomes]![ysnSentByMailToStaff]=0") _
& " new job outcome e-mail(s) to send." & Chr(10) & Chr(10) & "Would you like to send these now?", vbQuestion + vbYesNo, "You Have Unsent E-Mails..."

So the purpose is to ask the question, if any e-mails are unsent, "Do you want to send these now?"

If the user clicks no then the application should close down (application.quit) else exit the sub and return to the switchboard.

How do I take the users response to the question is the problem that I am having.

Any help apprieciated.

Graham
 
Tidy it up a little:


Code:
Dim intStore As Integer

intStore = DCount("[lngJobOutcome]", "[tblJobOutcomes]", "[ysnSentByMailToStaff]=0") 

If intStore = 0 Then
    DoCmd.Quit
Else
    If MsgBox("You have " & intStore & " new job outcome e-mail(s) to send." & vbCrLf & vbCrLf & "Would you like to send these now?", vbQuestion + vbYesNo, "You Have Unsent E-Mails...") = vbYes Then
        [b]do something[/b]
    Else
        DoCmd.Quit
    End If
End If
 
Last edited:
Hey Mile - Shoudn't that be:
__________________________________________
Dim intStore As Integer

intStore = DCount("[lngJobOutcome]", "[tblJobOutcomes]", "[ysnSentByMailToStaff]=0")

If intStore = 0 Then
DoCmd.Quit
Else
If MsgBox("You have " & intStore & " new job outcome e-mail(s) to send." & vbCrLf & vbCrLf & "Would you like to send these now?", vbQuestion + vbYesNo, "You Have Unsent E-Mails...") = vbYes Then
do something
Else
DoCmd.Quit
End If
End If
___________________________________________

Maybe your trying to do something else though...? Sorry about jumping in on your response if you are :D - just trying to help!

Take Care,
Kev
 
lol - should have been ELSE (edited it now)
 
Thanks Mile and Kevin

Got it working now using:

Code:
Private Sub cmdExitDatabase_Click()

Dim intStore As Integer
'Count of unsent e-mails
intStore = DCount("[lngJobOutcome]", "[tblJobOutcomes]", "[ysnSentByMailToStaff]=0")
'If count of unsent e-mails is zero then application will quit
'If count of unsent e-mails is greater than zero, msgbox will prompt to send mail.
'If user response is Yes then return to switchboard else quit application.
    If intStore = 0 Then
        DoCmd.Quit
        ElseIf MsgBox("You have " & intStore & " new job outcome e-mail(s) to send." & vbCrLf & vbCrLf & "Would you like to send these now?", vbQuestion + vbYesNo, "You Have Unsent E-Mails...") = vbYes Then
        Exit Sub
        Else
        MsgBox "Good Bye", , "Application Closing"
        DoCmd.Quit
    End If
End Sub

Thanks for the advice

Graham
 

Users who are viewing this thread

Back
Top Bottom