I am in the process of coverting a jet MDB to an ADP. I've noticed some weird behavior in regards to saving data on a form.
My forms are closed using a command button that basically does this:
This normally works. I've noticed that when there is a primary key violoation, I get this error:
Run-Time error '2757':
There was a problem accessing a propery or method of the OLE object.
I also get this error if I try to run: "RunCommand acCmdSaveRecord"
However, if I close the form manually (not using the button) or save using the Menu (Records->Save Record) I would get the expected msg box stating there is a primary key violation and you cannot save this record.
Why don't I get a message like that when I run this stuff from code?
If I just run "DoCmd.Close acForm, frm.Name" the form will close and NOT prompt that there is a key violation and it will not save. So that isn't good either.
How do I close a form using a button so that is prompts about a key violation without giving strange errors or just closing with no warning?
My forms are closed using a command button that basically does this:
Code:
If frm.Dirty Then
frm.Dirty = False
End If
DoCmd.Close acForm, frm.Name
This normally works. I've noticed that when there is a primary key violoation, I get this error:
Run-Time error '2757':
There was a problem accessing a propery or method of the OLE object.
I also get this error if I try to run: "RunCommand acCmdSaveRecord"
However, if I close the form manually (not using the button) or save using the Menu (Records->Save Record) I would get the expected msg box stating there is a primary key violation and you cannot save this record.
Why don't I get a message like that when I run this stuff from code?
If I just run "DoCmd.Close acForm, frm.Name" the form will close and NOT prompt that there is a key violation and it will not save. So that isn't good either.
How do I close a form using a button so that is prompts about a key violation without giving strange errors or just closing with no warning?