DoCOM Close question

  • Thread starter Thread starter PowerPoint Jedi
  • Start date Start date
P

PowerPoint Jedi

Well I am back for more help, sorry just can't seem to figure it out

First I am using Access 2003 and VB 6.5

I wrote this private subroutine and for some reason seem to get a runtime
error. I want this sub routine to check is the closed field is "yes" if it
is it should run specified macro. This portion of the subroutine works. If
not yes I want it to close the form. This is what I wrote

Private Sub Form_Close()
If Forms![ERGR]![Closed] = "yes" Then
DoCmd.RunMacro "Transfer Closed ERGR", 1
Else
DoCmd.Close acForm, "ERGR", acSaveYes
End If
End Sub

When I close the form with the [clised] field a null I get a prompt asking
me if I want to save the changes (which I dont want to get, it SHOULD
automatically save) and this message
Run-time error 2501
the close action was canceled


Any clues as to what I did wrong. All I really want is it to check for yes
if not yes - save and close form
if yes run macro

Thanks for any help given.
 
Back
Top