D
DanNy
i wrote a VBA code myself for delete function, but its not work and show me
error message "you cant delete the database object 'xxx' while it's open".
i want to delete a record in form.
this is the code i wrote:
-----------------------------------------------------------
Private Sub del_Click()
On Error GoTo Err_del_Click
Msg = "are you sureï¹–" ' Define message.
style = VbMsgBoxStyle.vbDefaultButton1 Or _
VbMsgBoxStyle.vbInformation Or VbMsgBoxStyle.vbYesNo
title = "reminder ^_^" ' Define title.
' Display message.
response = MsgBox(Msg, style, title)
If response = VbMsgBoxResult.vbYes Then ' User chose yes.
DoCmd.Close acForm, "student"
DoCmd.DeleteObject acForm, "student"
Msg = "Deletedï¹—" ' Define message.
style = VbMsgBoxStyle.vbDefaultButton1 And _
VbMsgBoxStyle.vbInformation And VbMsgBoxStyle.vbYesNo
title = "reminder ^_^" ' Define title.
' Display message.
response = MsgBox(Msg, style, title)
Else
Exit_del_Click:
Exit Sub
Err_del_Click:
MsgBox Err.Description
Resume Exit_del_Click
End If
End Sub
_____________________________________________________________
can you check the error for me? thanks a lot!
error message "you cant delete the database object 'xxx' while it's open".
i want to delete a record in form.
this is the code i wrote:
-----------------------------------------------------------
Private Sub del_Click()
On Error GoTo Err_del_Click
Msg = "are you sureï¹–" ' Define message.
style = VbMsgBoxStyle.vbDefaultButton1 Or _
VbMsgBoxStyle.vbInformation Or VbMsgBoxStyle.vbYesNo
title = "reminder ^_^" ' Define title.
' Display message.
response = MsgBox(Msg, style, title)
If response = VbMsgBoxResult.vbYes Then ' User chose yes.
DoCmd.Close acForm, "student"
DoCmd.DeleteObject acForm, "student"
Msg = "Deletedï¹—" ' Define message.
style = VbMsgBoxStyle.vbDefaultButton1 And _
VbMsgBoxStyle.vbInformation And VbMsgBoxStyle.vbYesNo
title = "reminder ^_^" ' Define title.
' Display message.
response = MsgBox(Msg, style, title)
Else
Exit_del_Click:
Exit Sub
Err_del_Click:
MsgBox Err.Description
Resume Exit_del_Click
End If
End Sub
_____________________________________________________________
can you check the error for me? thanks a lot!