BeforeUpdate ( Cannot save record )

NOL

Registered User.
Local time
Today, 12:02
Joined
Jul 8, 2002
Messages
102
Hi

I have the following code in the BeforeUpdate event of my form :

Private Sub Form_BeforeUpdate(Cancel As Integer)

MsgBox "Before Saving"
'Preview Button on form not clicked
If GlobalLoginInd <> 1 Then
MsgBox "Save aborted"
DoCmd.SetWarnings False
Cancel = True
End If
End Sub

When I close the form usign the 'X' button , the OnError event gets activated ,showing err.number 0 and no description and gives me the following error :


You can't save this record at this time.
<application name> may have encountered an error while trying to save a record. If you close this object now, the data changes you made will be lost.
Do you want to close the database object anyway ?.


Any ideas as to why this happens?

Thanks,
Gina
 
Hi Pat ,

Thanx , left it on during testing by mistake.

Here's my new code:

Private Sub Form_BeforeUpdate(Cancel As Integer)
'Preview Button on form not clicked
If GlobalLoginInd = 0 Then
MsgBox "Save aborted"
Cancel = True
End if
End Sub


The form does not have a cancel (X) button. and there was no code written in its Close event
(It is closed using the (X) on the menu bar)

Following your sugestion , i put in the foll code both on form close and on form unload:

Private Sub Form_Close()
On Error GoTo err_form_close:
MsgBox " Exiting .. "
err_form_close:
MsgBox Err.Number & " " & Err.Description
Exit Sub
End Sub

I do get the message "Exiting ..." with error Number 0 and no desc . and following that the error "You can't save this record at this time. "

Where else should i be trapping this error

Thanx,
Gina
 
Last edited:
Hi ,

These are the others :
Form_GotFocus (DoCmd.Maximize)

Form_Activate (DoCmd.Maximize)

Form_Open (
DoCmd.Maximize
GlobalNetworkID = fNetworkID()
GlobalComputerName = fMachineName()
GlobalLoginInd = 0

Me.ViewAll.Visible = False
Me.ViewMy.Visible = False
Me.ViewMyActions.Visible = False

)

I added the same error trapping code to the OnError event as in close & unload

Thanx Pat.
 
Hi ,

I noticed that the error occurs after the Onerror event
and before OnUnload event

I also put a close (X) button on the form and used that to close it .

Gina.
 

Users who are viewing this thread

Back
Top Bottom