M
MartinR
I want the form to close automatically after the record has been
deleted. An info message appears after the deletion of the record, "no
curret record", that is why i have the error code to avoid this being
shown. But the form does not close, but instead displays a blank
record.
Can someone please help with my problem,thanks
Private Sub Back_Click()
On Error GoTo Err_Back_Click
Const MB_OK = 0, MB_OKCANCEL = 1 ' Define buttons.
Const MB_YESNOCANCEL = 3, MB_YESNO = 4
Const MB_ICONSTOP = 16, MB_ICONQUESTION = 32 ' Define icons.
Const MB_ICONEXCLAMATION = 48, MB_ICONINFORMATION = 64
Const MB_DEFBUTTON2 = 0, IDYES = 6, IDNO = 7 ' Define other.
Title = "Exit without adding image"
DgDef = MB_YESNO + MB_ICONSTOP + MB_DEFBUTTON2
Response = MsgBox("Are you sure you want to exit without adding
an image?", DgDef, Title)
If Response = IDYES Then
DoCmd.SetWarnings False
RunCommand acCmdDeleteRecord
DoCmd.Close acForm, Me.Name
DoCmd.SetWarnings True
Else
End If
Exit_Back_Click:
Exit Sub
Err_Back_Click:
If Err.Number <> 3021 Then
MsgBox Err.Description
End If
Resume Exit_Back_Click
End Sub
deleted. An info message appears after the deletion of the record, "no
curret record", that is why i have the error code to avoid this being
shown. But the form does not close, but instead displays a blank
record.
Can someone please help with my problem,thanks
Private Sub Back_Click()
On Error GoTo Err_Back_Click
Const MB_OK = 0, MB_OKCANCEL = 1 ' Define buttons.
Const MB_YESNOCANCEL = 3, MB_YESNO = 4
Const MB_ICONSTOP = 16, MB_ICONQUESTION = 32 ' Define icons.
Const MB_ICONEXCLAMATION = 48, MB_ICONINFORMATION = 64
Const MB_DEFBUTTON2 = 0, IDYES = 6, IDNO = 7 ' Define other.
Title = "Exit without adding image"
DgDef = MB_YESNO + MB_ICONSTOP + MB_DEFBUTTON2
Response = MsgBox("Are you sure you want to exit without adding
an image?", DgDef, Title)
If Response = IDYES Then
DoCmd.SetWarnings False
RunCommand acCmdDeleteRecord
DoCmd.Close acForm, Me.Name
DoCmd.SetWarnings True
Else
End If
Exit_Back_Click:
Exit Sub
Err_Back_Click:
If Err.Number <> 3021 Then
MsgBox Err.Description
End If
Resume Exit_Back_Click
End Sub