Invalid Use of Null

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Aftab Ahmad
    New Member
    • Jan 2015
    • 49

    Invalid Use of Null

    Hello!

    I am getting error as Run-Time Error '94' Invalid Use of Null on my code
    Code:
    DoCmd.OpenReport strReportName, ReportView, , strReportFilter, acWindowNormal
    What should I do?
  • Nauticalgent
    New Member
    • Oct 2015
    • 102

    #2
    Without knowing anything about your report, it seems your filter variable, “strReportFilte r” is Null. Do you know how to check it?

    Usually you could simply wrap you variable in the Nz() Function to avoid the errror: Nz(strReportVar iable,””). But in you case, this would only open a blank report.

    I would recommend some code that checked for the Null value and then alerted the user that there was no data to report. Some thing like:

    Code:
    IF IsNull(strReportFilter) Then
         MsgBoxd “No Data To Report”
    Else
         DoCmd.Open.....
    End If

    Comment

    • twinnyfo
      Recognized Expert Moderator Specialist
      • Nov 2011
      • 3653

      #3
      I also believe this error is related to your previous thread. Your filter could have a series of variables and parameters, and if only one null value is used incorrectly, you will get an invalid use of Null error. This could also be related to your underlying record source for the report. If there is an invalid use of Null there, you will also get the error. Does the report open properly without the filter?

      We cannot solve this problem until 1) we see how you are creating your filter string and 2) we see the underlying query/record source for the report.

      Comment

      Working...