Autoeng
05-16-2003, 10:39 AM
I have a form where 3 fields (ECNAnalyst, StartDate and StopDate) are passed to a query as criteria. If any of the 3 fields are empty I want to stop the procedure. My code is working if ALL 3 fields are empty but if 1 contains data it proceeds. What am I doing wrong?
Private Sub lblPrintButton_Click()
On Error GoTo lblPrintButton_Click_Err
If Not ECNAnalyst.Value = "" Then
Beep
MsgBox "Press ""OK"" to print the ECN's By Analyst And Date report. This form will close automatically when printing is completed.", vbInformation, "ECN's By Analyst And Date Report"
DoCmd.OpenReport "rptECNByAnalystAndDate", acNormal, "", ""
DoCmd.Close acForm, "frmDates2"
DoCmd.Close acForm, "frmprint"
Else: MsgBox "You must select an ECN Analyst before printing."
End If
If Not StartDate.Value = "" Then
Beep
MsgBox "Press ""OK"" to print the ECN's By Analyst And Date report. This form will close automatically when printing is completed.", vbInformation, "ECN's By Analyst And Date Report"
DoCmd.OpenReport "rptECNByAnalystAndDate", acNormal, "", ""
DoCmd.Close acForm, "frmDates2"
DoCmd.Close acForm, "frmprint"
Else: MsgBox "You must specify a start date before printing."
End If
If Not StopDate.Value = "" Then
Beep
MsgBox "Press ""OK"" to print the ECN's By Analyst And Date report. This form will close automatically when printing is completed.", vbInformation, "ECN's By Analyst And Date Report"
DoCmd.OpenReport "rptECNByAnalystAndDate", acNormal, "", ""
DoCmd.Close acForm, "frmDates2"
DoCmd.Close acForm, "frmprint"
Else: MsgBox "You must specify an end date before printing."
End If
lblPrintButton_Click_Exit:
Exit Sub
lblPrintButton_Click_Err:
MsgBox Error$
Resume lblPrintButton_Click_Exit
End Sub
Private Sub lblPrintButton_Click()
On Error GoTo lblPrintButton_Click_Err
If Not ECNAnalyst.Value = "" Then
Beep
MsgBox "Press ""OK"" to print the ECN's By Analyst And Date report. This form will close automatically when printing is completed.", vbInformation, "ECN's By Analyst And Date Report"
DoCmd.OpenReport "rptECNByAnalystAndDate", acNormal, "", ""
DoCmd.Close acForm, "frmDates2"
DoCmd.Close acForm, "frmprint"
Else: MsgBox "You must select an ECN Analyst before printing."
End If
If Not StartDate.Value = "" Then
Beep
MsgBox "Press ""OK"" to print the ECN's By Analyst And Date report. This form will close automatically when printing is completed.", vbInformation, "ECN's By Analyst And Date Report"
DoCmd.OpenReport "rptECNByAnalystAndDate", acNormal, "", ""
DoCmd.Close acForm, "frmDates2"
DoCmd.Close acForm, "frmprint"
Else: MsgBox "You must specify a start date before printing."
End If
If Not StopDate.Value = "" Then
Beep
MsgBox "Press ""OK"" to print the ECN's By Analyst And Date report. This form will close automatically when printing is completed.", vbInformation, "ECN's By Analyst And Date Report"
DoCmd.OpenReport "rptECNByAnalystAndDate", acNormal, "", ""
DoCmd.Close acForm, "frmDates2"
DoCmd.Close acForm, "frmprint"
Else: MsgBox "You must specify an end date before printing."
End If
lblPrintButton_Click_Exit:
Exit Sub
lblPrintButton_Click_Err:
MsgBox Error$
Resume lblPrintButton_Click_Exit
End Sub