ACC2: "Invalid Reference" Saving Record on Form with ButtonID: Q123858
|
Moderate: Requires basic macro, coding, and interoperability skills.
When you try to save a record by choosing a command button on a form that
runs a DoMenuItem action, you receive the following error message:
Invalid reference to field 'Form_BeforeUpdate'
The Cancel argument is being set in the form's BeforeUpdate event procedure.
There are two ways to work around this problem. The first method traps and handles the error, and the second cancels the event in a different manner.
Sub Button1_Click ()
On Error GoTo Err_Button1_Click
DoCmd DoMenuItem A_FORMBAR, A_FILE, A_SAVERECORD, , A_MENU_VER20
Exit_Button1_Click:
Exit Sub
Err_Button1_Click:
Select Case Err
Case 2465
MsgBox "Descriptive error message of your choice here"
Case Else
MsgBox Error$
End Select
Resume Exit_Button1_Click
End Sub
DoCmd CancelEvent
Cancel = True
Microsoft has confirmed this to be a problem in Microsoft Access version 2.0. This problem no longer occurs in Microsoft Access version 7.0.
The problem described above usually results in the error message "Invalid
reference to 'Form_BeforeUpdate'," but may also result in the error message
"Invalid reference to field 'Button0_Click'."
This problem can also occur if you call a macro instead of code in the
BeforeUpdate property. The only method of saving a record that works as you
expect is choosing Save Record from the File menu.
Sub Form_BeforeUpdate (Cancel As Integer)
Cancel = True
End Sub
Keywords : kberrmsg kbusage FmsProb
Version : 2.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: April 8, 1999