Results 1 to 7 of 7

Thread: Messages

  1. #1
    Join Date
    Dec 2003
    Location
    The Netherlands
    Posts
    98

    Unanswered: Messages

    Hi,

    I have a button to save and want to have a msgbox saying something like "well done, you saved the record". Is there an 'on success' possibility I can use in vb?
    Has anyone got any ideas on how I could do this?

    tres thanks!

  2. #2
    Join Date
    Jun 2003
    Location
    UK
    Posts
    68
    Sorry charlottevk I'm not quite sure what you mean. Do you wish to have a message box that pops up after you have pressed a save button? or do you only want the message if the save is successful?

    Paul

  3. #3
    Join Date
    Dec 2003
    Location
    The Netherlands
    Posts
    98
    I want the message to say that the save (or whatever) was successful.

  4. #4
    Join Date
    Jun 2003
    Location
    UK
    Posts
    68
    On the 'On Click' event of the botton cut and paste the following code:

    Private Sub cmdSave_Click()
    On Error GoTo Err_Save_Click


    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

    MsgBox "The record has been saved successfully", vbInformation, "System Info"

    Exit_Save_Click:
    Exit Sub

    Err_Save_Click:
    MsgBox "An error has occurred whilst saving this record", vbInformation, "System Info"
    Resume Exit_Save_Click

    End Sub

    The above assumes that the button is called cmdSave.

    Hope this is what you are looking for.

    Paul

  5. #5
    Join Date
    Dec 2003
    Location
    The Netherlands
    Posts
    98
    THANKYOU SO MUCH. This is exactly what I was looking for. I can't thank you enough!!

  6. #6
    Join Date
    Dec 2003
    Location
    The Netherlands
    Posts
    98
    What changes in the code for the message box if I want the system to ask if I really want to save (or delete or whatever)?

  7. #7
    Join Date
    Jun 2003
    Location
    UK
    Posts
    68
    This is quite a simplistic solution but should be what you are after.

    Private Sub cmdSave_Click()

    Dim strSaveChanges As String

    On Error GoTo Err_Save_Click

    strSaveChanges = MsgBox("Do you wish to save the changes?", vbYesNo, "System Info")

    If strSaveChanges = vbYes Then

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

    MsgBox "The record has been saved successfully", vbInformation, "System Info"

    Else

    DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70

    MsgBox "The changes have been removed", vbInformation, "System Info"


    End If

    Exit_Save_Click:
    Exit Sub

    Err_Save_Click:
    MsgBox "An error has occurred whilst saving this record", vbInformation, "System Info"
    Resume Exit_Save_Click

    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •