error message alternate colourd report when no data (1 Viewer)

rosst

New member
Local time
Today, 00:00
Joined
Oct 31, 2000
Messages
8
I have created a report which derives its values from a query which is supplied with criteria from two combo boxes on a form. In an effort to make records easy to view I set up a text box in the detail section in accordance with a tip I got from the Internet.

The text box is in the detail and the Control setting is =1
The running sum property is set to Overall and View / code was selected and the following inserted.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If [RunSum] Mod 2 = 1 Then
Me.Section(0).BackColor = 15852071
Else
Me.Section(0).BackColor = 8118583
End If
End Sub

The system works well giving an easy to read report.
The problem occurs when a combination of Critera are chosen for which there is no data.

I get the message Runtime error 2427
The expression may refer to an object that has no value such as form report etc.
The user has the choice to debug or end .
Is there something I can do which will result in the form still displaying with no data or with a message "no data" or similar.
I'm using Win95, Access 97.
Any help would be greatly appreciated. Cheers,
 

Fornatian

Dim Person
Local time
Today, 00:00
Joined
Sep 1, 2000
Messages
1,396
If the report still opens showing the correct data you want

enter:
If Error Resume Next

at the beginning of the code. be warned however that this will prevent any other errors showing.

Ian
 

accesswatch

Registered User.
Local time
Today, 00:00
Joined
Aug 12, 2000
Messages
72
You could also use the reports

On No Data
Event to display a message box and then cancel the report

Hope this helps
Trevor from www.accesswatch.co.uk
 

Users who are viewing this thread

Top Bottom