Solved Delete current record (1 Viewer)

swingline

Member
Local time
Today, 08:17
Joined
Feb 18, 2020
Messages
51
I have a form that only has a Richtext box on it and Save button. the only thing that happens when the button is clicked is
Code:
DoCmd.Close acForm, "Comments", acSaveYes
I want to add an If statement that checks if "Me.Comment" is blank and then deletes the record. For example, the user starts to write a comment but then uses Backspace to delete their text. I don't want the blank comment to be saved to the table.
 

namliam

The Mailman - AWF VIP
Local time
Today, 06:17
Joined
Aug 11, 2003
Messages
11,696
Strike that reverse it....

Make your form unbound and add a "save" button, prior to saving your data you can check what you are adding, if nothing then ... dont save it.
Also you can add a "cancel" button this way the user can opt not to save at all.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:17
Joined
May 7, 2009
Messages
19,169
Add code to the BeforeUpdate event of the Form:

Private sub form_beforeupdate(cancel as integer)
Cancel=(len(trim$([yourtextbox] & vbnullstring))=0)
If cancel then me.undo

end sub
 

Users who are viewing this thread

Top Bottom