I use this code and it works great to append records from a subform to a table.
The problem comes in when you make a typo, as the record is then already appended to the table where its stored.
I need to be able to correct an error in the subform, and then it appends the corrected data to the same line in the table where its stored, instead of creating a new line/record everytime you correct something and press enter
The problem comes in when you make a typo, as the record is then already appended to the table where its stored.
I need to be able to correct an error in the subform, and then it appends the corrected data to the same line in the table where its stored, instead of creating a new line/record everytime you correct something and press enter
Code:
Private Sub Form_AfterUpdate()
On Error GoTo Err_Form_AfterUpdate
Dim MyDB As DAO.Database
Dim rstEntry As DAO.Recordset
Set MyDB = CurrentDb
Set rstEntry = MyDB.OpenRecordset("Fis_CaptDataT", dbOpenDynaset, dbAppendOnly)
With rstEntry
.AddNew
![Client_lookup] = Me![Client_lookup]
![InvoiceDate] = Me![InvoiceDate]
![Item_Lookup] = Me![Item_Lookup]
![CPrice] = Me![Price]
![Providers] = Me![Providers]
![Supplier] = Me![Supplier Lookup]
![Order_No] = Me![Order_No]
![OrderQty] = Me![OrderQty]
![DataCapturer] = Me![DataCapturer]
![Transact] = Me![Transaction]
.Fields("Transaction" & CStr(Me![Transaction])) = Me![InvoiceQty]
.update
End With
rstEntry.close
Set rstEntry = Nothing
Exit_Form_AfterUpdate:
Exit Sub
Err_Form_AfterUpdate:
MsgBox Err.Description, vbExclamation, "Error in Form_AfterUpdate()"
Resume Exit_Form_AfterUpdate
End Sub
Comment