Reputation: 2185
I have built a function that checks to see if a primary key is already linked with a foreign key. If it is already linked it prompts the user to see if they want to overwrite the existing value. If it isn't already linked it just saves the value into the DB without ever prompting the user.
The issue that I am running into is that once my function has already performed the update, the DB form also tried to perform the update, resulting in a duplicate key error message.
I realize I could just unbind the controls on the on the form so that they didn't try to perform the update function, though for easy of use I want to keep those controls bound. So what other means do I have of canceling the form from performing the update and possibly to just get it to refresh with the new information? I am sure this is probably an easy thing to do though I don't really know the terms to search in google in order to find the answer.
Upvotes: 0
Views: 77
Reputation:
If you want to stay with this model the best you can do is to hook up on Form.BeforeUpdate Event and set the Cancel
flag to true, as well as call DoCmd.CancelEvent method.
When your code executed, it can call the Refresh method to query new values.
Hope this answers your question and solves the issue you have.
Upvotes: 1