Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No Records in Table

Status
Not open for further replies.

mondeoman

MIS
Dec 7, 2006
203
GB
I have a report called "rpt_Outstanding_Maintenance_Requests" which has a simple On Click event procedure
-------------------------------
Private Sub Label8_Click()


Dim stDocName As String

stDocName = "rpt_Outstanding_Maintenance_Requests"
DoCmd.OpenReport stDocName, acPreview


End Sub
________________________________________

However, if there are no records in the table (i.e. this is the first record) it returns to the debug window which has the followinf code:

---Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If FormatCount = 1 Then
Select Case Me![txt_Priority]
Case "Immediate"
'Red
Me![txt_Priority].ForeColor = RGB(255, 0, 0)
Case "Urgent"
'Orange
Me![txt_Priority].ForeColor = RGB(255, 102, 0)
Case "Routine"
'Default is Green
Me![txt_Priority].ForeColor = RGB(51, 204, 51)
Case Else 'Default
Me![txt_Priority].ForeColor = 0
End Select
End If
End Sub

----------

How can I make sure that this does not happen before the first record is entered please?
 
What do you have in the On NoData property of the report?

Let them hate - so long as they fear... Lucius Accius
 
Sorry Straybullet but have "what" in the On NoData property of the report?
 
What I meant was, do you have any instructions for the report as to what should be done in the case of no data (no records)? This would be done by using the On NoData property of the report.
Often, something along the lines of the following will be used:
MsgBox "No Records Found. Cancelling report.", vbOKOnly
Cancel = True
On Error Resume Next
If Err = 2501 Then
Cancel = True
End If
which will show a message box to the user indicating that no records were found and cancel the report opening.

Let them hate - so long as they fear... Lucius Accius
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top