Help prevent report from running

R

Randy

MS Access 2000. I have a report that is run from a cmd button on a form.
This fires the perameter update query, sql below and then a report is
imediately run. The problem is, if the input box from the query is left
blank, the report ("Summary by Certificate Number")
still runs but with a null value in the field "DateIssued" I need to
prevent the report from running if the input box is inadvertantly left
blank. Thanks in advance.

UPDATE QUERY BELOW:

UPDATE AnalysisForm SET AnalysisForm.DateIssued = [InsertDateIssued]
WHERE
(((AnalysisForm.CertNumber)=[Forms]![IncomingNotesheet]![CertNumber]));

REPORT BELOW:
Private Sub Summary_with_date_issued_Click()
On Error GoTo Err_Summary_with_date_issued_Click
Dim stDocName As String
Dim strWhere As String
DoCmd.SetWarnings False
If Me.Dirty Then 'Save any edits first.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "Field Note Not Selected. Please Select a Field Note To
Print"
Else
stDocName = "InsertDateIssued"
DoCmd.OpenQuery stDocName
stDocName = "Summary by Certificate Number"
DoCmd.OpenReport stDocName, acViewNormal, , strWhere
Exit_Summary_with_date_issued_Click:
Exit Sub
Err_Summary_with_date_issued_Click:
Resume Exit_Summary_with_date_issued_Click
DoCmd.SetWarnings True
End If
End Sub
 
M

Marshall Barton

Randy said:
MS Access 2000. I have a report that is run from a cmd button on a form.
This fires the perameter update query, sql below and then a report is
imediately run. The problem is, if the input box from the query is left
blank, the report ("Summary by Certificate Number")
still runs but with a null value in the field "DateIssued" I need to
prevent the report from running if the input box is inadvertantly left
blank. Thanks in advance.

UPDATE QUERY BELOW:

UPDATE AnalysisForm SET AnalysisForm.DateIssued = [InsertDateIssued]
WHERE
(((AnalysisForm.CertNumber)=[Forms]![IncomingNotesheet]![CertNumber]));

REPORT BELOW:
Private Sub Summary_with_date_issued_Click()
On Error GoTo Err_Summary_with_date_issued_Click
Dim stDocName As String
Dim strWhere As String
DoCmd.SetWarnings False
If Me.Dirty Then 'Save any edits first.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "Field Note Not Selected. Please Select a Field Note To
Print"
Else
stDocName = "InsertDateIssued"
DoCmd.OpenQuery stDocName
stDocName = "Summary by Certificate Number"
DoCmd.OpenReport stDocName, acViewNormal, , strWhere
Exit_Summary_with_date_issued_Click:
Exit Sub
Err_Summary_with_date_issued_Click:
Resume Exit_Summary_with_date_issued_Click
DoCmd.SetWarnings True
End If
End Sub

You should get rid of the parameter prompt in the query.
Instead, add a text box to the form for users to enter the
parameter value. The query's parameter would then look
like:
Forms!theform.thetextbox

This way the button's code can check if the text box is
filled in or not and generate a message box and skip opening
the report.

I can not see any purpose to openg a query before running
the report and I recommend that you remove that from your
code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top