need form unload procedure

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everyone,

I am trying to set some conditions in my form unload procedure in case a
user tries to close the form before some validation is performed.
(closingprocures is a function which validates)

Here is my code:

DoCmd.CancelEvent
If (ClosingProcedures = False) Then
Exit Sub
Else
DoCmd.Close acForm, Me.Name
End If

So, what happens is the form closes, which it shouldn't
then it gives me an error at the close form line, error 2501, The close
action was cancelled.

Does anyone know how to accomplish this?

Thanks in advanced,
 
Hi everyone,

I am trying to set some conditions in my form unload procedure in case a
user tries to close the form before some validation is performed.
(closingprocures is a function which validates)

Here is my code:

DoCmd.CancelEvent
If (ClosingProcedures = False) Then
Exit Sub
Else
DoCmd.Close acForm, Me.Name
End If

So, what happens is the form closes, which it shouldn't
then it gives me an error at the close form line, error 2501, The close
action was cancelled.

Does anyone know how to accomplish this?

Thanks in advanced,

after the doCmd.close you have to Exit Sub

otherwise the code is still running, but the FormObject is deleted
 
Hi Andy,

Thanks for quick response.

I tried your solution and that did not help. I received the same error.

Any suggestions?

Thanks so much,
D
 
Back
Top