'Close' Button

Alan R

Registered User.
Local time
Today, 19:16
Joined
Sep 11, 2006
Messages
70
Hi,

I have the following code associated with the onclick property of a button that is (supposedly) designed to check if the Date box is empty and if it is brings up a message giving the user a choice of whether to accept the empty box or cancel the Close Form to allow them to update the record. If the Date box is not null i.e. it contains a date, clicking the button should close the form. This is where the problem lies. With the date field populated, 'pressing' the Close Form button does nothing, press it a second time and it closes:confused: . Can anybody shed some light on this, it isn't a difficult function to implement surely but can i get it to work as i wish!!!


If IsNull(Me.DateofIssue) Then
If MsgBox("The Date of Issue is blank." & vbCrLf & _
"If that is ok - select OK, otherwise select Cancel and input the required Date of Issue.", vbOKCancel + vbExclamation, "No Date of Issue.") = vbCancel Then
Exit Sub
Else
DoCmd.Close
End If
End If

Many thanks

Alan
 
It sure is easier to read when you use the code tags. Add the RED lines.
Code:
If IsNull(Me.DateofIssue) Then
   If MsgBox("The Date of Issue is blank." & vbCrLf & _
      "If that is ok - select OK, otherwise select Cancel and input the required Date of Issue.", vbOKCancel + vbExclamation, "No Date of Issue.") = vbCancel Then
      Exit Sub
   Else
      DoCmd.Close
   End If
[B][COLOR="Red"]Else
   DoCmd.Close[/COLOR][/B]
End If
 
RG,

Many thanks, looking at your version it is obvious to me now why my version wouldn't work as i wanted.

Appreciate it you taking the time to help and respond.

Regards

Alan
 

Users who are viewing this thread

Back
Top Bottom