Results 1 to 4 of 4
  1. #1
    Rick West is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2009
    Posts
    90

    DoCmd.RunCommand acCmdSaveRecord

    I don't understand what this line of code does but I'm guessing it automatically saves the current record from my form to the underlying table. When it saves it I do not know.

    If that's correct then I'm messing it up somehow by adding 3 extra lines. See below.

    The following code works just fine as is but it doesn't work if I take out the three "rem-out" rows of code - why?

    It seems to me that it should run the append query in the middle - no problem. The append query works off the table where the data just got acCMDSaved but I'm no programmer. Help.

    Private Sub cmdExit_Click()
    If Len(Me.PN) > 0 And Len(Me.REV) > 0 And Len(Me.Part_Description) > 0 Then
    DoCmd.RunCommand acCmdSaveRecord
    'DoCmd.SetWarnings False
    'DoCmd.OpenQuery "Q_AppendPNDescER"
    'DoCmd.SetWarnings True
    Form_F_PartAdds.cboPNAddRev = Me.REV
    DoCmd.Close acForm, "F_PartNew"
    Else
    MsgBox "You must provide a value for PN, Rev, Description"


    End If

    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You are correct as to what it does, and it does it at the point the code executes, so the record on the form should be available to the query (if that's what you're saying isn't happening). You might try adding

    DoEvents

    right after that to give the record time to save. If that's not the problem, perhaps you can clarify what your issue is.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Rick West is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2009
    Posts
    90
    I fixed this a slightly different way but it worked. I moved the append query so it runs after the acCMDSaveRecord/close form event and I think it should be fine unless Murphy comes around.

    thanks for the help.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Glad you got it working. I suspect that just gave the record time to fully save, but there are always more than one way to skin a cat...much to the cat's dismay.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 5
    Last Post: 03-30-2010, 12:53 PM
  2. Email sent via DoCmd.SendObject
    By silverback in forum Programming
    Replies: 0
    Last Post: 10-29-2009, 06:26 AM
  3. Issues with DoCmd.GoToControl
    By RaMcHiP in forum Programming
    Replies: 1
    Last Post: 05-09-2009, 08:56 PM
  4. DoCmd.OpenForm Modification
    By alsoto in forum Forms
    Replies: 6
    Last Post: 05-01-2009, 07:28 AM
  5. DoCmd.SendObject Help
    By bgreer5050 in forum Programming
    Replies: 0
    Last Post: 01-12-2007, 06:27 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