MajP
You've got your good things, and you've got mine.
- Local time
- Today, 07:40
- Joined
- May 21, 2018
- Messages
- 9,940
Sorry, I am with Pat on this one. This is a self-inflicted wound. You are struggling with some of the basics of good form design, but at the same time you have added a whole bunch of unnecessary complexity by adding complicated and superfluous features. I have never figured out why people feel the need for coding a Save feature in Access. This would be the same as having a teenager and adding to them a "Get Bored", "Ask for Money", or "Complain Incessantly" button. These things are going to happen automatically by multiple paths, and you have to go out of your way not to make it happen. You do not have to create those features.
You have bigger problems than worrying about locking a form down for edits and additions.
f instead you do what Pat says and check everything in the form's before update this design would get so much easier. In the before update you can ask them to continue or cancel an do data validation. If they did not mean to add or edit something then give them a final chance to opt out.
@Pat Hartman don't you have a thread with good examples of this?
For example this just adds complexity.
So instead of checking before the record is saved (before update) and canceling, you allow a bad record to get saved, turn on and off warnings, then run code to remove it.
You have bigger problems than worrying about locking a form down for edits and additions.
f instead you do what Pat says and check everything in the form's before update this design would get so much easier. In the before update you can ask them to continue or cancel an do data validation. If they did not mean to add or edit something then give them a final chance to opt out.
@Pat Hartman don't you have a thread with good examples of this?
For example this just adds complexity.
Code:
Private Sub Position_AfterUpdate()
Dim c As Long
c = DCount("*", "PositionT", "Position='" & Forms!jobtitlef.Form.Position & "'")
If c > 0 Then
If MsgBox("WARNING! A course with same name already exists. Enter a unique value.", , "Duplicate record alert!") Then
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Exit Sub
End If
End If
End Sub