I've been going to hell and back with this one.
I've got a form that I'm using for data entry. Users enter data and then press a "Log Case" button to enter their userID and a timestamp. It is not essential that all cases be logged straight away but it is essential that a user be prompted to log a record if they try to navigate between records or to close the form.
I'm using the form's beforeUpdate event to execute this code and it's working fine for navigation between records. The user is prompted with a simple message box and asked if they are sure they want to leave the record unlogged. If they say no then whatever they were trying to go (e.g. go to next record) is cancelled (Cancel = True). If they say yes then they can carry on.
As I said, this is working perfectly fine for the navigation buttons. Closing the form however is getting me into trouble. There are two options:
1) Use the close button on the top right of the form.
2) Make an exit button on the form.
Using 1) in the case where a user does NOT want to leave the record unlogged produces the following error message:
"You can't save this record at this time
[FormName] may have encountered an error while trying to save a record. If you close this object now, the data changes you made will be lost. Do you want to close the database object anyway?"
Therefore I decided to use 2). The problem this time is that the DoCmd.Close command appears to be able to ignore the Cancel = True statement in the BeforeUpdate function.
Any and all assistance would be hugely appreciated because I'm going nuts.
I've got a form that I'm using for data entry. Users enter data and then press a "Log Case" button to enter their userID and a timestamp. It is not essential that all cases be logged straight away but it is essential that a user be prompted to log a record if they try to navigate between records or to close the form.
I'm using the form's beforeUpdate event to execute this code and it's working fine for navigation between records. The user is prompted with a simple message box and asked if they are sure they want to leave the record unlogged. If they say no then whatever they were trying to go (e.g. go to next record) is cancelled (Cancel = True). If they say yes then they can carry on.
As I said, this is working perfectly fine for the navigation buttons. Closing the form however is getting me into trouble. There are two options:
1) Use the close button on the top right of the form.
2) Make an exit button on the form.
Using 1) in the case where a user does NOT want to leave the record unlogged produces the following error message:
"You can't save this record at this time
[FormName] may have encountered an error while trying to save a record. If you close this object now, the data changes you made will be lost. Do you want to close the database object anyway?"
Therefore I decided to use 2). The problem this time is that the DoCmd.Close command appears to be able to ignore the Cancel = True statement in the BeforeUpdate function.
Any and all assistance would be hugely appreciated because I'm going nuts.