Data entered into memo not being saved (1 Viewer)

access2010

Registered User.
Local time
Today, 04:26
Joined
Dec 26, 2009
Messages
651
Using Access 2003 when we close a form with a memo, we have been using the following code.
===
Private Sub Save_Record_Click()
DoCmd.Close acForm, Me.Name
End Sub
===
But, we regularly receive this error
1605657629901.png


Please advise me what I should change our close the form code to, so that the record is saved?

Thank you,
Crystal
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:26
Joined
Oct 29, 2018
Messages
14,191
What was the error message?
 

Mike Krailo

Active member
Local time
Today, 07:26
Joined
Mar 28, 2020
Messages
194
Code:
Private Sub Save_Record_Click()
   If Me.Dirty Then
       DoCmd.RunCommand acCmdSaveRecord
   End If
   DoCmd.Close acForm, Me.Name
End Sub
 

arnelgp

error reading drive A:
Local time
Today, 20:26
Joined
May 7, 2009
Messages
11,582
closing the form will implicitly save the record.
maybe ignore the error:

Private Sub Save_Record_Click()
On Error Resume Next
DoCmd.Close acForm, Me.Name
End Sub

or

Private Sub Form_Error(DataErr As Integer, Response As Integer)
Response = acDataErrContinue
End Sub
 

access2010

Registered User.
Local time
Today, 04:26
Joined
Dec 26, 2009
Messages
651
What was the error message?

theDBguy
Sometimes after entering information into our memo and we close the form, a message pops up, if we want to save the record, which we reply yes.​

But some time the record shows, #Deleted.​

We will be trying Mike Krailo code and see if this fixes the problem.​


 

Mike Krailo

Active member
Local time
Today, 07:26
Joined
Mar 28, 2020
Messages
194
The only strange thing about this is that in order to see the #Deleted in your form, the record would have to have been saved already and then something deleted it. There is no way to get that message without it already being in the table. So my question is: In post #1, does that screen shot show the memo field with the #Deleted message, or is that some other field? Maybe there is some other code that is being triggered to do this deletion.

1605707590785.png


Not my words, but found this on an internet search for a similar issue:
Your edits could be causing the underlying recordset to change in a way that Access can't interpret (thus the #DELETED). Probably a key or index violation of some kind. You'll need to use DAO Recordset to find and store what record should be current after the requery then use Recordset move methods to get it there.

There is another possibility for this if using SQL Server as a backend and not using a timestamp field. If you are using a standard DAO backend or non-split database, this shouldn't be a problem.
 
Last edited:

missinglinq

AWF VIP
Local time
Today, 07:26
Joined
Jun 20, 2003
Messages
6,402
Not sure why Access would be popping the 'Deleted' message (not that the Access Gnomes are known for being accurate in their error messages) but prior to v2007, if you forced a Save by simply closing a Form...and one or more Required Fields were left empty, Access would Close the Form without Saving the Record. Mike's code forces the Save and avoids this problem (meaning it'll tell you if a Required Field is empty) and I suspect is at the bottom of the problem. Access can behave very strangely when dealing with Memo Fields!


Linq ;0)>
 

access2010

Registered User.
Local time
Today, 04:26
Joined
Dec 26, 2009
Messages
651
This error message has reoccurred.
1606263627457.png

Could I please be advised how to try and fix this problem.

Thank you.
Nicole
 

Mike Krailo

Active member
Local time
Today, 07:26
Joined
Mar 28, 2020
Messages
194
That's not a problem, it's just two users editing the same record at close to the same time. The more users you have accessing the same database, the more chance that you will get that message. It's just a warning that if you edit the record, you will wipe out the current changes made by the other user. My question to you is how often does that occur and how many users are accessing the database? Obviously this is not desirable, but it should be a rare occurrence and not something that you see all the time. All users should be informed about how to react to this situation. They should allow the other user to complete the edit and wait their turn (Drop Changes). Maybe not what you wanted to hear but it's not possible for two users to edit the same record at the same time. Kind of like the movie Highlander: "There can be only one."
 

access2010

Registered User.
Local time
Today, 04:26
Joined
Dec 26, 2009
Messages
651
Mike, thank you for your note.
This error message occurs INFREQUENTLY.
I think that the last time it happened was about 3 weeks ago.
Crystal
 

Users who are viewing this thread

Top Bottom