Joe Hecht
jmhecht at earthlink.net
Thu Feb 16 22:10:19 CST 2006
The following code is supposed to check that 1. The start date is not null 2. The end date is not null. If either is null I want a message box( that works) and when user clicks ok they go back to form. It is not working. Can any one see why? Thanks Private Sub cmdAccEndDate_Click() Dim lngRetval As Long Dim strStDocName As String Dim lngRetval1 As Long Dim lngRetval2 As Long Dim CANCEL As Boolean Me.txtAccEndDate = Me.calAccEndDate 'Sets end date If IsNull(Me.txtAccStartDate) Then 'Confirm Start Date is not null lngRetval1 = MsgBox( _ "There is no Start Date Entered." & vbCrLf & "" & vbCrLf & "Please select a Start Date", _ vbOKOnly + vbCritical + vbDefaultButton1, _ "PLEASE ENTER START DATE") Select Case lngRetval1 Case vbOK CANCEL = True End Select End If If IsNull(Me.txtAccEndDate) Then 'Confirm End Date is not null lngRetval1 = MsgBox( _ "There is no End Date Entered." & vbCrLf & "" & vbCrLf & "Please select a Start Date", _ vbOKOnly + vbCritical + vbDefaultButton1, _ "PLEASE ENTER END DATE") Select Case lngRetval1 Case vbOK CANCEL = True End Select End If If Me.txtAccStartDate > Me.txtAccEndDate Then lngRetval = MsgBox( _ "The start date must be the same as, or before the end date of the report." & vbCrLf & "" & vbCrLf & "Please review the selected dates and try your report again", _ vbOKOnly + vbCritical + vbDefaultButton1, _ "INCORECT DATE INPUT") Select Case lngRetval Case vbOK End Select Else ' Dim stDocName As String strStDocName = "30_rptAccidentRegister" DoCmd.OpenReport strStDocName, acPreview DoCmd.RunCommand acCmdZoom100 Joe Hecht jmhecht at earthlink.net