Results 1 to 4 of 4
  1. #1
    musicopr is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2017
    Posts
    2

    Angry DoCmd.RunCommand acCmdSaveRecord Problem

    Hi, to everyone. I have the following issue. I have a form with a subform and a save button. When i press the button it looks for a duplicate and if there is no duplicate it show a msgbox asking if i want to add or no the new record. if i press yes it save the data into the table. If i press NO it also saved the data into the table. So what i want is that when i press no that it stop and not perform the cmdsaverecord. Here is the code i have


    Code:
    Private Sub cmdSaveRecord_Click()Dim response As Integer
    
    
    If IsNull(Me.HS_Parts) _
    Or IsNull(Me.frmAdd_UTC_PartNumber_Vendor_Subform.Controls(ID)) Then
    MsgBox "HS PART OR VENDOR INFORMATION ID IS EMPTY,THOSE FIELDS ARE REQUIRED", vbCritical
       
        
    Else
       response = MsgBox("Do you really wants to add this record? ", vbYesNo + vbQuestion, "Add Record")
        If response = vbYes Then
        
        DoCmd.RunCommand acCmdSaveRecord
         
            MsgBox "Not Added"
       
       
       Else
            MsgBox "Record not Added", vbCritical
       End If
       End If
    I don't know what else to do. Even i deleted the docmd.runcommand acCmdSaveRecord and it still saving the data into the table. help plz

  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
    52,891
    A record (or edits to existing record) is committed to table when 1. close table/query/form or 2. move to another record or 3. run code.

    If you want to not save the entry then need to UNDO. Try Me.Undo in the Else.

    Why is the message "Not Added" when you save the record?
    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
    musicopr is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2017
    Posts
    2
    Quote Originally Posted by June7 View Post
    A record (or edits to existing record) is committed to table when 1. close table/query/form or 2. move to another record or 3. run code.

    If you want to not save the entry then need to UNDO. Try Me.Undo in the Else.

    Why is the message "Not Added" when you save the record?
    I forgot to erase it from there it should be say Record Added. But what i notice is that when i start entering data and i done entering data it save to the table automatically.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,891
    What does 'done' mean - are you moving to another record row?

    Suggested code works for me but I do not move to another record row.
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 09-27-2016, 09:10 PM
  2. docmd.runcommand accmdpaste - data is NULL
    By dickn in forum Programming
    Replies: 7
    Last Post: 07-16-2013, 04:27 PM
  3. RunCommand acCmdSaveRecord
    By apotter in forum Programming
    Replies: 1
    Last Post: 03-26-2012, 11:46 PM
  4. Replies: 0
    Last Post: 06-17-2010, 04:51 AM
  5. DoCmd.RunCommand acCmdSaveRecord
    By Rick West in forum Programming
    Replies: 3
    Last Post: 04-22-2010, 02:52 PM

Tags for this Thread

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