ACC: Edits Not Processed w/ Close Action on Form (2.0, 7.0, 97)ID: Q131813
|
Moderate: Requires basic macro, coding, and interoperability skills.
When you edit a record in a form, the editing changes are not processed
when the form is closed with a macro's Close action. However, you are not
prompted with any error messages as to why the changes are not saved.
The Close action is invoked with the DoCmd method in Visual Basic for
Applications (or the DoCmd statement in Access Basic in Microsoft Access
2.0) and the current record is not processed because a validation error has
occurred. The following validation errors can prevent editing changes from
being processed when the form closes:
To work around this problem, force the record to be saved before the Close action is run by using the following RunCommand method (or DoMenuItem method in Microsoft Access 2.0 and 7.0) to select Save Record on the Records menu (or File menu in Microsoft Access 2.0).
DoCmd.RunCommand acCmdSaveRecord
NOTE: In Microsoft Access 97, the DoMenuItem method has been replaced by
the RunCommand method. The DoMenuItem method is included in Microsoft
Access 97 only for compatibility with earlier versions.
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord,, acMenuVer70
DoCmd DoMenuItem A_FormBar, A_File, A_SaveRecord, , A_Menu_Ver20
Private Sub CloseForm_Click()
On Error GoTo Err_CloseForm_Click
DoCmd.Close
Exit_CloseForm_Click:
Exit Sub
Err_CloseForm_Click:
MsgBox Err.Description
Resume Exit_CloseForm_Click
End Sub
Sub CloseForm_Click ()
On Error GoTo Err_CloseForm_Click
DoCmd Close
Exit_CloseForm_Click:
Exit Sub
Err_CloseForm_Click:
MsgBox Error$
Resume Exit_CloseForm_Click
End Sub
Microsoft has confirmed this to be a problem in Microsoft Access versions 2.0, 7.0, and 97. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
The field 'Customers.CompanyName' can't contain a Null value because The Required property for this field is set to True. Enter a value in this field.
Microsoft Access
You can't save this record at this time. Microsoft Access may have
encountered an error while trying to save a record. If you close
this object now, the data changes may be lost.
Do you want to close the Database object anyway?
Field 'Customers.Company Name' can't contain a null value.
The record being edited can't be saved. If you close the form, the changes you've made to the record will be lost. Close anyway?
For more information about the Close action, search the Help Index for "Close action," or ask the Microsoft Access 97 Office Assistant.
Keywords : kbusage McrProb
Version : 2.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: April 26, 1999