Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2006
    Posts
    126

    Unanswered: Record save when moving from Detail to Header

    I have an form that consists of a header with an unbound control that is used to select the record shown in Detail. This works correctly.

    In the Detail section are the fields from the master table and sub-forms with fields from linked tables. Everything works fine with one exception:
    If info in a field in Detail is updated and then the unbound header control is selected, and another name entered; the VBA code to find the requested record doesn't get executed [Runtime Error 3020; Update or Cancel Update without AddNew or Edit], and eventually there is a message:
    You can't save this record at this time.
    Microsoft Access may have encountered an error while trying to save a record.
    If you close this object now, the data changes you made will be lost.
    Do you want to close the database object anyway?

    Clicking the DeBug in the 3020 error message highlights the Me! line in the Code for the form:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Me![DateLastUpdate].Value = Now()
    End Sub

    I've taken to doing a PgUp or PgDn after doing my work so the changes are processed prior to clicking in the Header field.

    What is the best solution for this. Do I need to change the Form_BeforeUpdate and make one for each field, (I hope not)?

    Pete T.
    PGT

  2. #2
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    496
    Provided Answers: 24
    It sounds like somewhere between the record didnt finish saving , or it started another edit...
    Put a save record code at txtBOX in the header ON GOT FOCUS event
    to ensure the save.

    Code:
    sub txtbox_ongotfocus()
    on error resume next
    DoCmd.RunCommand acCmdSaveRecord

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
  •