Results 1 to 2 of 2

Thread: CR and VB

  1. #1

    Thread Starter
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    CR and VB

    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]
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  2. #2
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951
    I would set up a couple papramer fields on the report and when you call the report:

    Report.ParameterFields.Item(1).AddCurrentValue [Inv_Unit]
    Report.ParameterFields.Item(2).AddCurrentValue [Debrief_CNT]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width