Re: Report Error With No Data

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



rmcompute wrote:

I set up code to read a table of reports and run them and then export to Excel:

DoCmd.OpenReport Me.cboReportType, acViewPreview

strReportxls = strPath & Me.cboReportType & ".xls"
DoCmd.OutputTo acOutputReport, Me.cboReportType, acFormatXLS,
strReportxls, False

Inside the report is code for a heading:
=DLookUp("StartDate","tblSRRptPeriod","RptPeriod = '" & [RptPeriod] & " ' ")

The report exports to Excel fine, but when there is no data abends from the
DLookup. I tried testing for a null RptPeriod (The field in the table), but
that did not work. Is there a way after issuing this command:
DoCmd.OpenReport Me.cboReportType, acViewPreview, to NOT issue the next
command if there was no data ?


Generally, you should use the report's NoData event to
Cancel the report.

--
Marsh
MVP [MS Access]
.



Relevant Pages

  • Re: Help!! Im running around in circles!
    ... whatever is causing this. ... I changed acViewNormal to acViewPreview and this seems to now ... >> Private Sub OK_Click ... >>> should not open the report itself. ...
    (microsoft.public.access.gettingstarted)
  • Re: Coding with varsortby and options
    ... DoCmd.OpenReport stDocName, acViewPreview ... MsgBox "No Report Selected." ... Dim varhowsort As Variant ...
    (microsoft.public.access.formscoding)
  • Re: Failure of OpenDatabase Method
    ... Dim rptTitle As String ... Dim dbsAnother As Database ... DoCmd.OpenReport Me.cboReports, acViewPreview ... The OpenCurrentDatabase method is required to open a report in a separate ...
    (comp.databases.ms-access)
  • Re: Add criteria to function
    ... The main reason I suggested the Where arguement is the code in the criteria ... that the "via query" approach I offerred might be a bit easier ... ... DoCmd.OpenReport Me!cboReportName, acViewPreview,, strWhere ... new report, it looks like you'll need to remember to edit the If...Else ...
    (microsoft.public.access.forms)
  • Re: Saving changes on form before running a report
    ... On the Command button (that you already use to open the report) ... When the code window opens, the cursor will be flashing between 2 ... DoCmd.OpenReport "ReportName", acViewPreview ...
    (microsoft.public.access.forms)