Q: How do you print a 0 in a report summary column when there are NO records? I get #error.
A: One way is to use syntax similar to the following in the control source for the summary field. It first tests if the report has an empty record source or no. If it does it prints a 0. Otherwise, if there is data, it takes the sum (or other aggregate function).
Yes, here is the code to do it. I got it from databasedev.co.uk and modified it for our factory2000 sample case. It will spell check a comments field I added to the labor tickets. It uses the RunCommand method of DoCmd.
Private Sub memComments_AfterUpdate() 'If the comments field contains data run the 'Spell Checker after data is entered. If Len(Me!memComments & "") > 0 Then DoCmd.RunCommand acCmdSpelling Else Exit Sub End If End Sub
I will post a sample database to our sample database collection later. I will also cross post this to the Access VBA thread.
Here is the code to print report lines in alternating colors like the old greenbar reports. I got it from Blue Claw Database Design. Obviously a nice touch if you have time would be to put it in a library module. This one alternates between light grey and the default.
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) If Me.Detail.BackColor = 16777215 Then Me.Detail.BackColor = 12632256 Else Me.Detail.BackColor = 16777215 End If End Sub