3 Replies - 5492 Views - Last Post: 09 April 2012 - 11:12 AM Rate Topic: -----

#1 hwkong1688  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 30-September 11

runtime error '94' invalid use of null when view data report?

Posted 04 April 2012 - 11:38 PM

Hi,
When i view my report got this error, runtime error '94' invalid use of null, but my database all have data?? if i use 'on error resume next' will blank report. Anyone can help me to re-solve this problem,Thank you.

your help is much appreciated.
Public Sub SumSH()
RS1Check
rs1.Open "Select sum(sh) From Daily where dt between #" & DTPicker2 & "# and #" & DTPicker3 & "#", cn, adOpenDynamic, adLockPessimistic
Text1.Text = rs1.Fields(0) 'THIS LINE CAUSE THE ERROR[/color]
End Sub

Private Sub ViewReport_Click()

On Error GoTo 0

If MsgBox("          View Report?", vbYesNo, "View Report") = vbYes Then
DataReport1.Orientation = rptOrientLandscape

DataEnvironment1.Commands(1).CommandText = "Select * From Daily Where Dt Between #" & DTPicker2 & "# and #" & DTPicker3 & "# Order by Dt"

DataReport1.Show

SumSH

Load DataEnvironment1
With DataEnvironment1
If .rsCommand1.State <> 0 Then .rsCommand1.Close
.Command1
End With

Else
Cancel = 1
End If

End Sub



Is This A Good Question/Topic? 0
  • +

Replies To: runtime error '94' invalid use of null when view data report?

#2 maj3091  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,776
  • Joined: 26-March 09

Re: runtime error '94' invalid use of null when view data report?

Posted 05 April 2012 - 12:09 AM

As a guess, I would say that your query is returning nothing?

Using resume next is just masking the error, hence the reason you get a blank report.

Put a breakpoint on the error line and sing the debug tools, have a look what RS1's state is after the query.

Also in your query, you may have to use the value property of the datepicker control.
Was This Post Helpful? 0
  • +
  • -

#3 hwkong1688  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 30-September 11

Re: runtime error '94' invalid use of null when view data report?

Posted 05 April 2012 - 01:05 AM

the RS1.state code is:
Public Sub RS1Check()
If rs1.State = 1 Then rs1.Close
End Sub


Was This Post Helpful? 0
  • +
  • -

#4 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: runtime error '94' invalid use of null when view data report?

Posted 09 April 2012 - 11:12 AM

It almost certainly means that your dataset has a null value in it somewhere, whether you think so or not. Another possibility is that your datareport is referencing a field that it doesn't intend to, but I don't know dr as well as the rest.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1