Hi all,
I know a couple of users have had this same issue, and I have had a look around many of the posts on the issue and tested some of the code but I cant get it to work properly. Please bear with me, I'm fairly new and self taught to this stuff so it has mainly been trial and error.
I have an access database with a bound form. The form is used purely for data entry purposes and currently is set up so that when the user selects a button called save and submit it processes the record and moves the form on to the next blank record (I have removed normal navigation buttons)
Code I currently have in the database is as follows:
Option Compare Database
Private Sub cboSubGroup_Change()
Me.txtCost_centre.Value = Me.cboSubGroup.Column(1)
Me.txtInternal_Order_No.Value = Me.cboSubGroup.Column(2)
Me.txtStatistical_Internal_Order.Value = Me.cboSubGroup.Column(3)
End Sub
Private Sub SaveCommand_Click()
DoCmd.GoToRecord , , acNewRec
End Sub
What I now want to do is make it so that the records will not save unless the save and submit button is clicked, so for instance if the user starts accidentally typing a record and then closes the database the record will not save. There are lots of users who expect it to work in the way of excel etc where if you close it will not save changes if you have not clicked save – even though this is not how access works.
So when the user goes to close the database or form I would like to pop up a warning (only if the save button has not been clicked) saying “would you like to discard changes?” Yes or No. If the user selects Yes it will then wipe the database and allow them to close it. If the user selects No then it should not close the database but leave the record open to edit and save. If the save button has been clicked and a new record has been opened with no changes i.e. the form is not dirty, and the user wants to close the database then it should override the warning and just close as normal.
I know this is possible using the Before Update event in the form, I just can’t get the right combination of code to be able to function properly.
Any help at all would be much appreciated.
I know a couple of users have had this same issue, and I have had a look around many of the posts on the issue and tested some of the code but I cant get it to work properly. Please bear with me, I'm fairly new and self taught to this stuff so it has mainly been trial and error.
I have an access database with a bound form. The form is used purely for data entry purposes and currently is set up so that when the user selects a button called save and submit it processes the record and moves the form on to the next blank record (I have removed normal navigation buttons)
Code I currently have in the database is as follows:
Option Compare Database
Private Sub cboSubGroup_Change()
Me.txtCost_centre.Value = Me.cboSubGroup.Column(1)
Me.txtInternal_Order_No.Value = Me.cboSubGroup.Column(2)
Me.txtStatistical_Internal_Order.Value = Me.cboSubGroup.Column(3)
End Sub
Private Sub SaveCommand_Click()
DoCmd.GoToRecord , , acNewRec
End Sub
What I now want to do is make it so that the records will not save unless the save and submit button is clicked, so for instance if the user starts accidentally typing a record and then closes the database the record will not save. There are lots of users who expect it to work in the way of excel etc where if you close it will not save changes if you have not clicked save – even though this is not how access works.
So when the user goes to close the database or form I would like to pop up a warning (only if the save button has not been clicked) saying “would you like to discard changes?” Yes or No. If the user selects Yes it will then wipe the database and allow them to close it. If the user selects No then it should not close the database but leave the record open to edit and save. If the save button has been clicked and a new record has been opened with no changes i.e. the form is not dirty, and the user wants to close the database then it should override the warning and just close as normal.
I know this is possible using the Before Update event in the form, I just can’t get the right combination of code to be able to function properly.
Any help at all would be much appreciated.