Results 1 to 5 of 5

Thread: Crystal Report in VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Location
    Auckland NZ
    Posts
    8

    Exclamation Crystal Report in VB

    Hi,
    I want to know how to print a crystal report file from vb - using vb code. I get no errors but not getting print or preview.

    The code I use.
    crystalreport1.ReportFileName = GenPath & "order.rpt"
    crystalreport1.SQLQuery = strSql
    crystalreport1.Destination = crptToWindow
    crystalreport1.PrintReport

    Can anyone help to find the bug here.
    Thanks in advance

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Add:

    CrystalReport1.Action = 1

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Location
    Auckland NZ
    Posts
    8
    Thanks Hack,

    When I used CrystalReport1.Action = 1, I get the error msg as

    Unable to connect; incorrect log on parameters

    for some reason. Do you know why this error comes up? I connected the db, it did not referring to db connection.

    Thanks again

  4. #4
    Frenzied Member oh1mie's Avatar
    Join Date
    Sep 2001
    Location
    Finland
    Posts
    1,043

    Re: Crystal Report in VB

    You can built connection with Report designer on the same time when You modified report.

    On VB code You are giving just Reportilename and some othert options.
    VB Code:
    1. subEmptyCrystal
    2.  
    3.  With frmLogo.CrystalReport1
    4.     If sSQL <> "" Then .SelectionFormula = sSQL
    5.     .WindowTitle = "MyReport"
    6.     .Formulas(0) = "Money=' " & strMoney & "'"
    7.     .DataFiles(0) = App.Path & "\MyDatabase1.Mdb"
    8.     .DataFiles(1) = = App.Path & "\MyDatabase2.Mdb"
    9.     .DataFiles(2) = = App.Path & "\MyDatabase3.Mdb"
    10.     .ReportFileName = App.Path & "\MyRaport.rpt"
    11.     .Action = 1
    12.  End With
    13.  
    14. Allways empty Crystalreport variables befor You giving Newones
    15.  
    16. Like calling sub ..
    17.  
    18. Public Sub subEmptyCrystal()
    19.    
    20.     Dim i As Integer
    21.    
    22.     With CrystalReport1
    23.         For i = 0 To 100
    24.             .SortFields(i) = ""
    25.             .Formulas(i) = ""
    26.         Next
    27.         .PrinterCopies = 1
    28.         .Destination = 1
    29.         .SelectionFormula = ""
    30.         .WindowTitle = ""
    31.         .ReportTitle = ""
    32.         For i = 0 To 100
    33.             .DataFiles(i) = ""
    34.         Next
    35.     End With
    36.  
    37. End sub
    Last edited by oh1mie; Apr 20th, 2002 at 10:24 AM.
    oh1mie/Vic


  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Thanks oh1mie. I actually had to do some work today, so I didn't get the chance to get back to the forum until now.

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