Results 1 to 4 of 4
  1. #1
    Evgeny's Avatar
    Evgeny is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    85

    Close Button Functions

    hi guys, i have a close button on the form, if the form is dirty it pops up the message "do you want to save changes"?. My problem is that i can close the form when its not dirty, but when then msg pop us and hit either Yes or No it does nothing. Please suggest if the code below is right (only begginer in Vba) :

    Private Sub cmd_CloseCustomerInfo_Click()

    Dim Answer As String

    If Me.Dirty Then

    MsgBox "Do you want save changes?", vbQuestion + vbYesNo

    Select Case Answer

    Case vbYes



    DoCmd.RunCommand acCmdSaveRecord

    DoCmd.RunCommand acCmdClose

    Case vbNo

    DoCmd.RunCommand acCmdClose

    End Select

    Else

    DoCmd.RunCommand acCmdClose

    End If

    End Sub

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Private Sub cmd_CloseCustomerInfo_Click()

    Dim Answer As String

    If Me.Dirty Then

    MsgBox "Do you want save changes?", vbQuestion + vbYesNo

    Select Case Answer

    Case vbYes

    DoCmd.RunCommand acCmdSaveRecord

    DoCmd.RunCommand acCmdClose

    Case vbNo

    DoCmd.RunCommand acCmdClose

    End Select

    Else

    DoCmd.RunCommand acCmdClose

    End If

    End Sub

    Replace the line highlighted in Red with this one:

    Answer = MsgBox("Do you want save changes?", vbQuestion + vbYesNo)

  3. #3
    Evgeny's Avatar
    Evgeny is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    85
    oh god, i knew its gonna be something simple. Thank you once again

  4. #4
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    mark it solved......

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

Similar Threads

  1. Close All but One Form
    By Bruce in forum Forms
    Replies: 4
    Last Post: 04-06-2010, 09:31 AM
  2. Functions
    By jamin14 in forum Programming
    Replies: 1
    Last Post: 03-25-2010, 08:16 AM
  3. Close DAP Connection
    By gfultz in forum Access
    Replies: 0
    Last Post: 10-16-2009, 10:11 AM
  4. Replies: 4
    Last Post: 09-10-2009, 03:09 AM
  5. close form
    By taylorosso in forum Forms
    Replies: 5
    Last Post: 08-25-2009, 12:18 PM

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