VBA Code to close Find dialog needed, or custom find control - Update or CancelUpdate Without AddEdit or New error (1 Viewer)

Local time
Today, 15:34
Joined
Feb 28, 2023
Messages
628
Cancel = True cancels the save. It does NOT stop the form from being dirty . You need to use
Me.Undo
Cancel = True
to perform both actions.
I don't claim to be the expert and I'm not even saying you are wrong. What you wrote is correct, but it isn't what I am doing.

Cancel = True by itself would probably leave the error message - not sure.

What I have is Me.Undo without Cancel=True.

Technically what that does (I think) is undoes all the changes (including the date modified field) and then SAVES the record.

Like the Word analogy, it's the difference between opening a Word file, adding a space and clicking Close and don't save changes as opposed to removing the space and closing and saving. The file date is different, but the file is essentially the same.

Could you see my question in Reply #16?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:34
Joined
Feb 19, 2002
Messages
43,280
What is the point of saving a record that has not been changed?
 
Local time
Today, 15:34
Joined
Feb 28, 2023
Messages
628
No point except that it saves a mouse-click as I said above. (If I change the record and click Find Next, without Cancel = True, I am prompted to save or not and then it goes to the next record. If I change the record and click Find Next with Cancel = True, I am prompted to save or not and then it stays on the current record and I have to click find again.)

And it wasn't my choice, but by default (with BeforeUpdate() code added) Access saves every change and updates the database file date every time it is opened.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:34
Joined
Feb 19, 2002
Messages
43,280
Thanks for posting your solution. You're lucky your users are not using Replace to update the tables. I would not use this method.
 
Local time
Today, 15:34
Joined
Feb 28, 2023
Messages
628
Thanks to all who replied for their assistance!!!

Understood. I'm also fortunate the database isn't really setup where we routinely have to change the same value to some other value - so there aren't a lot of examples where replace would be useful.
 

Users who are viewing this thread

Top Bottom