I\'m migrating an Access database to SQL Server using the SQL Server Migration Assistant (SSMA). The Access application will continue to be used but with linked tables inst
I solve this problem via writing AfterUpdate form-event like this:
Private Sub Form_BeforeUpdate(Cancel As Integer)
cSQL = "update UnderlinedTable set Field1=" & Me.Controls("Field1") & _
", Field2=" & Me.Controls("Field2") & _ ' and all other fields in your form
" where PrimaryKey=" & Me.Recordset.Fields("PrimaryKeyField")
' here command to SQL server that executes this cSQL string
Me.Requery
Cancel = True 'stop Access updating
end sub
It is possible to be wriiten universal BeforeUpdate form-event function that generates automatically Update statement based on form.recordsource and changed form fields that can be invoked from all AfterUpdate form-events passing form as parameter. I have made this for me.
After much trial and error I solved the issue. In the enter event handler for the sub form control on the main form, I requeried the sub form itself.
eg On the main form:
Private Sub Subform1_Enter()
Me.Subform1.Form.Requery
End Sub
I don't know why this works, only that it does.
This happens when a record is updated in a table, but the record source of the main form has not been refreshed to reflect the change, so Access gets conflicting information and thinks the record has been changed. See also: http://support.microsoft.com/kb/302492