Why does my datareport print my labels 4 times?

I have two labels on a datareport, just to test to see if I can use it.

It works ok, the data appears on the report- except it appears 4 times!


any body know why?


VB Code:
  1. Dim airsamplepass As Long
  2. Dim airsamplefail As Long
  3. Dim airsamplesum As Long
  4.  
  5.  
  6. Dim Cnxn As ADODB.Connection
  7. Set Cnxn = New ADODB.Connection
  8. Dim Record As New ADODB.Recordset
  9.  
  10.  
  11. Dim strQuery As String
  12. Dim todaysdate As Date
  13. Dim todaysdate2 As Date
  14. todaysdate = Date
  15. todaysdate2 = Date + 1
  16. todaysdate = Mid(todaysdate, 4, 3) & Mid(todaysdate, 1, 3) & Mid(todaysdate, 7, 4)
  17. todaysdate2 = Mid(todaysdate2, 4, 3) & Mid(todaysdate2, 1, 3) & Mid(todaysdate2, 7, 4)
  18. ' todaysdate = Format(todaysdate, "dd/mm/yyyy hh:mm:ss")
  19.  
  20. ' select all the records from the CIP table for LINE1
  21. strQuery = "SELECT Result FROM CIP WHERE LineNumber = 'Line1'"
  22. ' open the connection to the DB
  23. Cnxn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\VB_Projects\MICRO_LAB\DB\MICRO_RESULTS.mdb;Persist Security Info=False"
  24. Record.Open strQuery, Cnxn, adUseClient
  25.  
  26.  
  27.  
  28. MsgBox Record.RecordCount
  29.  
  30. airsamplesum = Record.RecordCount
  31. Cnxn.Close
  32.  
  33. strQuery = "SELECT Result FROM CIP WHERE LineNumber = 'Line1' AND Passed = 'Yes'"
  34. ' open the connection to the DB
  35.  
  36. Cnxn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\VB_Projects\MICRO_LAB\DB\MICRO_RESULTS.mdb;Persist Security Info=False"
  37. Record.Open strQuery, Cnxn, adUseClient
  38. 'MsgBox strQuery
  39. MsgBox Record.RecordCount
  40. airsamplepass = Record.RecordCount
  41. 'this line is a way of allowing the report to be refreshed with new data.
  42. 'Otherwise, old data will reappear even if the report is first closed and reopened.
  43. If DataEnvironment1.rsCommand1.State = adStateOpen Then DataEnvironment1.rsCommand1.Close
  44.  
  45.  
  46.  
  47. DataReport1.Sections("Section1").Controls("Label1").Caption = airsamplesum
  48. DataReport1.Sections("Section1").Controls("Label2").Caption = airsamplepass
  49.  
  50. DataReport1.Show
  51. 'allows a refresh with new data without having to close the report first.
  52. DataReport1.Refresh
  53. 'DataReport1.Show