Slaam to all.
hey everyone.
i have form with some txt fields and close button.
i want that when user click on close button then access generate a message with yes and no button.
which is such as" Are you sure to close Application" vb yes or no
when use press yes then access check only two fields for null and if both or one null then record not saved in table all things work good but only saving issued not solved. for this purpose i used cancel = true if msgbox = vbyes but it save the record even both fields are empty. what problem with code I cann't understand.
the code behind close button is :
-------------------------------------------------------------------------
Code:
Private Sub cmdClose_Click()
Dim strmsg As String
On Error GoTo Err_cmdClose_Click
strmsg = "Are you sure to close Application"
If MsgBox(strmsg, vbQuestion + vbYesNo, "Close Application") = vbYes Then
If IsNull(Me.WithDrawAmount) Or IsNull(Me.Description) Then
MsgBox ("Record will be not saved")
End If
Cancel = True
DoCmd.Close acForm, "WithDrawSpecial"
Else
If IsNull(Me.WithDrawAmount) Or IsNull(Me.Description) Then
Me.WithDrawAmount.BorderColor = vbRed
Me.Description.BorderColor = vbRed
End If
End If
Exit_cmdClose_Click:
Exit Sub
Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click
End Sub
----------------------------------------------------------------
any ideas, suggestion, will be appreciated.