Results 1 to 3 of 3
  1. #1
    thart21 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    83

    Message box issues.

    Hoping someone could take a look at my VBA below and tell me why my database is closing even when I select "No" in my message boxes.



    This code starts after I run queries and send a report to Excel.

    Sub TestMsg()
    msg = "File has been exported to Excel, Send Email to Users?"
    button = vbYesNo + vbDefaultButton2
    response = MsgBox(msg, button)

    If response = vbYes Then
    Call SendMail
    MsgBox "Mail sent, Quit Access?", vbYesNo
    If vbYes Then - db closes when I hit "No" too
    DoCmd.Quit
    ElseIf response = vbNo Then
    MsgBox "Quit Access Now?", vbYesNo - Not getting this msg to appear
    If vbYes Then
    DoCmd.Quit
    End If
    End If
    End If

    End Sub

    Thanks,

    Toni

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Try

    If MsgBox... = vbYes Then
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    AccessTheWayAhead is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2010
    Posts
    3
    Try this, I find it easier to read at least:

    If response = vbYes Then
    Call SendMail
    if MsgBox("Mail sent, Quit Access?", vbYesNo)= vbYes Then
    ' db closes when I hit "No" too
    DoCmd.Quit
    ElseIf response = vbNo Then
    if MsgBox("Quit Access Now?", vbYesNo) = vbyes then
    '- Not getting this msg to appear
    DoCmd.Quit
    End If
    End If
    End If

    David

Please reply to this thread with any new information or opinions.

Similar Threads

  1. error message
    By ngeng4 in forum Forms
    Replies: 85
    Last Post: 03-25-2010, 06:47 AM
  2. the message #Name? in the text
    By grad2009 in forum Forms
    Replies: 7
    Last Post: 02-22-2010, 05:41 PM
  3. SendObject Message
    By williammarino in forum Forms
    Replies: 4
    Last Post: 10-06-2009, 01:54 AM
  4. message box help
    By shaz10010 in forum Forms
    Replies: 1
    Last Post: 04-17-2009, 09:11 AM
  5. Message in Field
    By supatsiri in forum Reports
    Replies: 0
    Last Post: 03-09-2009, 01:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums