I have an Access 2003 front end that is linked to a separate Access 2003 back end database. I have written some VBA in the After Update event on a form to allow a field on the form to be autofilled when another field is changed. This appears to work fine, but when I change to another record after running it, I get a "Write Conflict" error. I'm given the option to "Save Changes" or "Drop Changes". If I "save changes" then my SQL code changes aren't kept. If I "Drop changes", then the result of the SQL code are kept. I'm currently working in a test database on my PC, so no one else has access to it.
I found solutions to this problem all over the web, however they are all based on having a SQL Server backend, and adding a Timestamp field to the table. The field I am updating is a date field, and I'm not using SQL Server.
The SQL code in the VBA appears to work fine, but I'll post it below because it's better to have too much info. If anyone has an idea, I appreciate any help.
Thanks
Dim SQLStr As String
Dim CurrentFile As String
DoCmd.SetWarnings (False)
CurrentFile = [Forms]![frmCP_Main]![CP_FileNo]
SQLStr = "SELECT cv_Fileno, MAX(CV_Voucher_DT) AS MaxPayment_Dt INTO TempFinalPmt FROM [CP-CustPrimary] INNER JOIN [CV-CustVoucher] ON [CP-CustPrimary].CP_FileNo = [CV-CustVoucher].CV_FileNo WHERE CP_FinalPayment_Dt IS NULL AND cp_Fileno = """ & CurrentFile & """ GROUP BY CV_FileNo;"
DoCmd.RunSQL SQLStr
DoCmd.RunSQL "UPDATE TempFinalPmt INNER JOIN [CP-CustPrimary] ON TempFinalPmt.cv_Fileno = [CP-CustPrimary].CP_FileNo SET [CP-CustPrimary].CP_FinalPayment_Dt = [maxpayment_dt];"
DoCmd.SetWarnings (True)