Results 1 to 3 of 3

Thread: [RESOLVED] Load a Report Programmatically

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Location
    Madison, WI
    Posts
    136

    Resolved [RESOLVED] Load a Report Programmatically

    I got this code from a book but there are errors all over this:

    VB Code:
    1. Me.Cursor = Cursors.WaitCursor
    2.  
    3.         Try
    4.             Dim oRpt As New ReportDocument
    5.             oRpt.Load("..\Reports\" & strTransaction)
    6.             Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
    7.             Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo
    8.  
    9.             For Each tbCurrent In oRpt.Database.Tables
    10.                 tliCurrent = tbCurrent.LogOnInfo
    11.                 With tliCurrent.ConnectionInfo
    12.                     .ServerName = "localhost"
    13.                     .UserID = "sa"
    14.                     .Password = "corbin"
    15.                     .DatabaseName = "BiWeekly"
    16.                 End With
    17.                 tbCurrent.ApplyLogOnInfo(tliCurrent)
    18.             Next tbCurrent
    19.             viewer.ReportSource = oRpt
    20.  
    21.         Catch ex As Exception
    22.             MsgBox(ex.Message)
    23.         Finally
    24.             Me.Cursor = Cursors.Default
    25.         End Try

    The errors are saying:
    Cannot find custom tool 'CrystalDecisions.VSDesigner.CodeGen.ReportCodeGenerator' on this system.
    Name 'viewer' is not declared
    Name 'strTransaction' is not declared.
    Type 'CrystalDecisions.CrystalReports.Engine.Table' is not defined
    Type 'CrystalDecisions.Shared.TableLogOnInfo' is not defined
    Type 'ReportDocument' is not defined

    I need some advice how to resolve these issues.

    Thanks.
    Last edited by callydata; Oct 6th, 2005 at 10:03 AM.

  2. #2
    Hyperactive Member
    Join Date
    Mar 2005
    Location
    Manila, Philippines
    Posts
    486

    Re: Load a Report Programmatically

    have you referenced your crystal report on your project?

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Load a Report Programmatically

    Looks like your using vb.net with Option Explicit on. So you need to declare the strTransaction for starters. the rest of the problems will be fixed if you add the reference to Crystal and place the CR Viewer control on your form.
    VB Code:
    1. Me.Cursor = Cursors.WaitCursor
    2.  
    3.     Try
    4.         Dim strTransaction As String
    5.         Dim oRpt As New ReportDocument
    6.         oRpt.Load("..\Reports\" & strTransaction)
    7.         Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
    8.         Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo
    9.  
    10.         For Each tbCurrent In oRpt.Database.Tables
    11.             tliCurrent = tbCurrent.LogOnInfo
    12.             With tliCurrent.ConnectionInfo
    13.                 .ServerName = "localhost"
    14.                 .UserID = "sa"
    15.                 .Password = "corbin"
    16.                 .DatabaseName = "BiWeekly"
    17.             End With
    18.             tbCurrent.ApplyLogOnInfo(tliCurrent)
    19.         Next tbCurrent
    20.         viewer.ReportSource = oRpt
    21.  
    22.     Catch ex As Exception
    23.         MsgBox(ex.Message)
    24.     Finally
    25.         Me.Cursor = Cursors.Default
    26.     End Try
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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