Update error when assigning value to a form field

J

John

Hi

In the exit event of a bound form field when I assign a value to another
bound form field I get the error 'Update or CancelUpdate without AddNew or
Edit' error. Code is as below;

Private Sub Field1_Exit(Cancel As Integer)
[Field2] = "Value" 'This line generates error
End Sub

I thought access handled Addnew and Edit automatically for bound forms. What
is going on here?

Thanks

Regards
 
G

Guest

You are addressing the field in the recordset, not the control on the form.
This causes that error.
If the field in the recordset has the exact same name as the control on the
form Access can get confused about which you are addressing, particularly if
you are not qualifying your references.
If [Field2] is the name of both, it may help to qualify your reference
Me.[Field2] = "Value"

Also, you have this in the Exit event. That is not the correct place to put
code like this. It should be in the After Update event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top