Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Location
    Scotland
    Posts
    24

    Red face Unanswered: Using a button to save a record

    Hi,

    prob a simple question but i'm stumped!!

    How can i use a button to save a record on a form (to a table [Booking]).

    for example a user fills out details then presses a save button (btnSave) [which saves the record]

    or

    a cancel button (btnCancel) which clears the form and exits without saving.

    Should be simple - but i'm drawing a blank!

    Any pointers

    TIA
    Cam

  2. #2
    Join Date
    Mar 2004
    Location
    www.scirocco.ca
    Posts
    346

    Re: Using a button to save a record

    Add three buttons to your form, cmdSave, cmdUndo and cmdClose and then add this three sub-procedures:

    ------------------------------------------------
    Private Sub cmdUndo_Click()
    On Error GoTo Err_cmdUndo_Click


    DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70

    Exit_cmdUndo_Click:
    Exit Sub

    Err_cmdUndo_Click:
    MsgBox Err.Description
    Resume Exit_cmdUndo_Click

    End Sub
    ------------------------------------------------
    Private Sub cmdSave_Click()
    On Error GoTo Err_cmdSave_Click


    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

    Exit_cmdSave_Click:
    Exit Sub

    Err_cmdSave_Click:
    MsgBox Err.Description
    Resume Exit_cmdSave_Click

    End Sub
    ------------------------------------------------
    Private Sub cmdClose_Click()
    On Error GoTo Err_cmdClose_Click


    DoCmd.Close

    Exit_cmdClose_Click:
    Exit Sub

    Err_cmdClose_Click:
    MsgBox Err.Description
    Resume Exit_cmdClose_Click

    End Sub
    http://www.scirocco.ca/images/banner...occobanner.gif

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

  3. #3
    Join Date
    Apr 2004
    Location
    Scotland
    Posts
    24

    Thanks -further Q

    Thanks!

    How can i change the exit button so that it does not save the record automatically (when the close (exit) button is pressed) - but requires the user to press the save button?

    TIA

Posting Permissions

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