Results 1 to 3 of 3
  1. #1
    redekopp is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2015
    Location
    Saskatoon
    Posts
    108

    Saving and cancelling data input in a form


    Hey there, I think I've got myself confused a bit. I have created simple forms that pop up to add new items to a specific table. Example being adding a new interior colour to the list of interior colour choices.

    you click the "add" button the form opens to a new record. you type in an interior colour in the intcolour field and click save or cancel. What am I doing so that the save and cancel button actually either allows or denies this new entry from sticking?

    right now im doing:
    Code:
    DoCmd.Close acForm, "frmInteriorColour", acSaveYes
    for the save button
    and
    Code:
    DoCmd.Close acForm, "frmInteriorColour", acSaveNo
    for the cancel button

    No matter which one u choose if you have typed something into the intcolour field its been added to the table.

    How do I make it based on the save and cancel buttons only?

    Thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,649
    The acSaveYes and acSaveNo have nothing to do with saving data, they pertain to saving design changes of the form. This is because code can be utilized to change some properties during runtime. But usually it is not desired to make these changes permanent, hence acSaveNo when closing the form.

    Data is committed to table when closing form, moving to another record, or running code. One code example is: DoCmd.RunCommand acCmdSaveRecord

    Using a button to abort record commitment can be tricky. This might involve command to 'undo' the inputs or somehow pass value to form BeforeUpdate event as parameter to Cancel.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    redekopp is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2015
    Location
    Saskatoon
    Posts
    108
    Would it work if I make the cancel button clear the fields before closing? or would it save moving from one field to the next, if there is more then one data field on the form?


    EDIT: I tried this, but all it does is make the one field have a null entry, still creates the automatic ID for the colours. sigh.
    DOUBLE EDIT: DoCmd.RunCommand acCmdUndo fixed my issue. just adding that before the close command.. Thanks for the help June!

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

Similar Threads

  1. Replies: 4
    Last Post: 04-25-2015, 09:27 AM
  2. Replies: 6
    Last Post: 04-04-2015, 08:10 AM
  3. Closing form without saving data
    By Thompyt in forum Programming
    Replies: 5
    Last Post: 03-28-2015, 02:55 PM
  4. Replies: 12
    Last Post: 12-31-2014, 09:30 AM
  5. Saving data back into a table from a form
    By skyview chick in forum Forms
    Replies: 22
    Last Post: 08-15-2012, 05:43 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