am on the verge (I think confused: ) of finally printing reports using cr 8.5, but I am stuck. Please help me, here is my code:


VB Code:
  1. Private Sub PrintDebreifingsCR()
  2.  
  3. Dim rs As Recordset      'Record set to load cboUserName data
  4. Dim strTypeConnection As String 'Connection type (i.e. SQL -1)
  5. Dim strDataBaseName As String   'Database Name
  6. Dim strDBName As String         'Sets Database Name
  7. Dim strDBCursorType As String   'Cursor (Dynamic, Forward Only, Keyset, Static)
  8. Dim strDBLockType As String     'Locks (BatchOptimistic,Optimistic,Pessimistic
  9.                                 'Read Only)
  10. Dim strDBOptions As String      'DB Options
  11. Dim UserActionText As String
  12. Dim strSQL As String
  13. Dim CommandCount As Long
  14. Dim InvUnit As String
  15. Dim Debrief_Count As String
  16. Dim Debrief_Max As String
  17. Dim SearchYear As String
  18.  
  19. SearchYear = ""
  20. SearchYear = CStr(Me.Text6.Text)
  21.  
  22. strTypeConnection = "5"          'SQL Database
  23. strDataBaseName = "Debrief"      'Database Connection String
  24. strDBCursorType = adOpenDynamic  'CursorType
  25. strDBLockType = adLockOptimistic   'LockType
  26. strDBOptions = adCmdText         'Options
  27.  
  28. Set rs = New Recordset       'Creates record set
  29.    
  30.         strSQL = "SELECT tblIABCommands.Inv_Unit, "
  31.         strSQL = strSQL & "COUNT(tblDebriefing.Debrief_Num) AS UnboundString1, "
  32.         strSQL = strSQL & "MAX(tblDebriefing.Debrief_Num) As Debrief_Max, "
  33.         strSQL = strSQL & "SUBSTRING(tblDebriefing.Debrief_Num, 1, 4) "
  34.         strSQL = strSQL & "FROM tblDebriefing RIGHT OUTER JOIN tblIABCommands ON "
  35.         strSQL = strSQL & "tblDebriefing.Inv_Unit = tblIABCommands.Inv_Unit "
  36.         strSQL = strSQL & "GROUP BY tblIABCommands.Inv_Unit, tblIABCommands.Sort2, (SUBSTRING(tblDebriefing.Debrief_Num, 1, 4)) "
  37.         strSQL = strSQL & "HAVING (tblIABCommands.Inv_Unit LIKE N'Group%') AND "
  38.         strSQL = strSQL & "(SUBSTRING(tblDebriefing.Debrief_Num, 1, 4) = '" & SearchYear & "') "
  39.         strSQL = strSQL & "ORDER BY tblIABCommands.Sort2;"
  40.        
  41.         Set rs = New Recordset       'Creates record set
  42.        
  43.         rs.Open strSQL, _
  44.             ConnectString(strTypeConnection, strDataBaseName), _
  45.                 strDBCursorType, _
  46.                 strDBLockType, _
  47.                 strDBOptions
  48.    
  49.  
  50. If rs.EOF = True Then
  51.     MsgBox "There are no Debriefing records for Calendar Year - " & SearchYear, vbCritical, "No Debriefing Data - " & SearchYear
  52. Else
  53.  
  54.     With CrystalReport1
  55.         .ReportFileName = App.Path & "\CrystalReport1.rpt"
  56.         .DiscardSavedData = True
  57.         .RetrieveDataFiles
  58.         .ReportSource = 0
  59.         .ReportTitle = "Employee Details Report"
  60.         .Destination = crptToWindow
  61.         .PrintFileType = crptCrystal
  62.         .WindowState = crptMaximized
  63.         .WindowMaxButton = False
  64.         .WindowMinButton = False
  65.     End With
  66.        
  67. End If
  68. rs.Close
  69. Set rs = Nothing

From my SQL I have two (2) fields that I want to display on the report: [Inv_Unit] and [Debrief_CNT]. How would I send this data to CrystalReport1? What type of fields would I need on the report and what should I name them?

Once Someone points me in the right direction I should be able to figure this out.

Thanks in advance!!!: [Highlight=VB][CODE]