Hi,
I have a form that is set to continuous form. It contains the days of the months and has alerts if a day is missing and/or a user tries to enter a date that is already present. The alert that tells the user that the date is already present populates on the before update event. This is all working fine. Finally, the sql table that is the form's control source does not allow duplicate dates for a store number. This is working fine as well.
My issue is that when the user enters a duplicate date I need the date that was just entered to be removed. The code I've tried runs after the user clicks "OK" on the message box that alerts that a duplicate date has been entered. I have used Me.SERVICE_DATE.Undo, Cancel = True, and docmd.runcommand acCmdUndo, all of which remove the duplicate date that was entered. However the focus stays on the row and unless the user hits the escape button and sets the focus elsewhere, the DB throws an ODBC error. If I try to reset the focus in code on the before update or after update events I get an error that the record needs to be saved before the focus can be reset. I do not want the record saved.
I've even tried using code that saves the record and then deletes it but that didn't work.
I'm admitting defeat and reaching out for education on what I'm doing wrong.
Thanks,
Leesha
Undo command
-
- 2StarLounger
- Posts: 104
- Joined: 22 Feb 2022, 09:04
Re: Undo command
Have you tried
Me.Dirty = False ? before setting focus?
Me.Dirty = False ? before setting focus?
Using Access 2007/2019.
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
Please, please use code tags when posting code snippets, click the </>icon.
Debug.Print is your lifesaver.
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
Please, please use code tags when posting code snippets, click the </>icon.
Debug.Print is your lifesaver.
-
- BronzeLounger
- Posts: 1488
- Joined: 05 Feb 2010, 22:25
Re: Undo command
Hi Gasman,
That did the trick!
Thanks!
Leesha
That did the trick!
Thanks!
Leesha