Results 1 to 14 of 14

Thread: please look at the code

  1. #1

    Thread Starter
    Hyperactive Member fasi's Avatar
    Join Date
    Nov 2000
    Posts
    474

    please look at the code

    Can some one please look at the code and tell me whats wrong with it .. I have been doing this thing for a long time .. everything in the code works but when it gets to the last line where i am trying to print the report out it gives me an error that the print routine failed .. but it still prints all the reports ..

    Dim Report As New CrystalReport1

    Private Sub Form_Load()
    Dim TransDate As Date
    Dim tempDay As String

    tempDay = Format(Date, "dddd")
    If tempDay = "Monday" Then
    TransDate = Format(Date - 5, "m/d/yyyy")
    Else
    TransDate = Format(Date - 3, "m/d/yyyy")
    End If


    Screen.MousePointer = vbHourglass
    CRViewer1.ReportSource = Report


    Report.EnableParameterPrompting = False
    Report.ReadRecords
    Set params = Report.ParameterFields


    For Each param In params
    With param

    .ClearCurrentValueAndRange

    If .Name = "{?InsertDate}" Then
    .AddCurrentValue TransDate
    End If


    End With
    Next

    CRViewer1.ViewReport

    Screen.MousePointer = vbDefault

    End Sub

    Private Sub Form_Resize()

    CRViewer1.Top = 0
    CRViewer1.Left = 0
    CRViewer1.Height = ScaleHeight
    CRViewer1.Width = ScaleWidth
    Report.PrintOut False

    End Sub

  2. #2
    Frenzied Member andreys's Avatar
    Join Date
    Sep 2002
    Location
    Los Angeles
    Posts
    1,615
    Could you please edit your message so we could see code more clear. Just put CODE in square brackets [] before your code starts and /CODE after its ends.

  3. #3

    Thread Starter
    Hyperactive Member fasi's Avatar
    Join Date
    Nov 2000
    Posts
    474
    here you go

    codeim Report As New CrystalReport1

    Private Sub Form_Load()
    Dim TransDate As Date
    Dim tempDay As String

    tempDay = Format(Date, "dddd")
    If tempDay = "Monday" Then
    TransDate = Format(Date - 5, "m/d/yyyy")
    Else
    TransDate = Format(Date - 3, "m/d/yyyy")
    End If


    Screen.MousePointer = vbHourglass
    CRViewer1.ReportSource = Report


    Report.EnableParameterPrompting = False
    Report.ReadRecords
    Set params = Report.ParameterFields


    For Each param In params
    With param

    .ClearCurrentValueAndRange

    If .Name = "{?InsertDate}" Then
    .AddCurrentValue TransDate
    End If


    End With
    Next

    CRViewer1.ViewReport

    Screen.MousePointer = vbDefault

    End Sub

    Private Sub Form_Resize()

    CRViewer1.Top = 0
    CRViewer1.Left = 0
    CRViewer1.Height = ScaleHeight
    CRViewer1.Width = ScaleWidth
    Report.PrintOut False

    End Sub

  4. #4
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    Re: please look at the code

    He meant that you should do put these tags: [vbcode][/vbcode] to make it more readable. Liek this:


    VB Code:
    1. Dim Report As New CrystalReport1
    2.  
    3. Private Sub Form_Load()
    4. Dim TransDate As Date
    5. Dim tempDay As String
    6.  
    7. tempDay = Format(Date, "dddd")
    8.     If tempDay = "Monday" Then
    9.         TransDate = Format(Date - 5, "m/d/yyyy")
    10.     Else
    11.         TransDate = Format(Date - 3, "m/d/yyyy")
    12.     End If
    13.  
    14.  
    15. Screen.MousePointer = vbHourglass
    16. CRViewer1.ReportSource = Report
    17.  
    18.  
    19.     Report.EnableParameterPrompting = False
    20.     Report.ReadRecords
    21.     Set params = Report.ParameterFields
    22.    
    23.        
    24.     For Each param In params
    25.         With param
    26.        
    27.             .ClearCurrentValueAndRange
    28.            
    29.             If .Name = "{?InsertDate}" Then
    30.                 .AddCurrentValue TransDate
    31.             End If
    32.            
    33.            
    34.         End With
    35.     Next
    36.    
    37.     CRViewer1.ViewReport
    38.    
    39. Screen.MousePointer = vbDefault
    40.  
    41. End Sub
    42.  
    43. Private Sub Form_Resize()
    44.  
    45. CRViewer1.Top = 0
    46. CRViewer1.Left = 0
    47. CRViewer1.Height = ScaleHeight
    48. CRViewer1.Width = ScaleWidth
    49. Report.PrintOut False
    50.  
    51. End Sub

    Besides, post a better subject. "Please look at the code" means nothing to me.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  5. #5

    Thread Starter
    Hyperactive Member fasi's Avatar
    Join Date
    Nov 2000
    Posts
    474
    Code:
    Dim Report As New CrystalReport1
    
    Private Sub Form_Load()
    Dim TransDate As Date
    Dim tempDay As String
    
    tempDay = Format(Date, "dddd")
        If tempDay = "Monday" Then
            TransDate = Format(Date - 5, "m/d/yyyy")
        Else
            TransDate = Format(Date - 3, "m/d/yyyy")
        End If
    
    
    Screen.MousePointer = vbHourglass
    CRViewer1.ReportSource = Report
    
    
        Report.EnableParameterPrompting = False
        Report.ReadRecords
        Set params = Report.ParameterFields
        
            
        For Each param In params
            With param
            
                .ClearCurrentValueAndRange
                
                If .Name = "{?InsertDate}" Then
                    .AddCurrentValue TransDate
                End If
                
               
            End With
        Next
        
        CRViewer1.ViewReport
        
    Screen.MousePointer = vbDefault
    
    End Sub
    
    Private Sub Form_Resize()
    
    CRViewer1.Top = 0
    CRViewer1.Left = 0
    CRViewer1.Height = ScaleHeight
    CRViewer1.Width = ScaleWidth
    Report.PrintOut False
    
    End Sub

  6. #6

    Thread Starter
    Hyperactive Member fasi's Avatar
    Join Date
    Nov 2000
    Posts
    474
    Thanx,

    But can you guys see now why is it giving me this error

  7. #7
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    much better... if you use vbcode instead of code tags, your code gets colored, as well.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  8. #8
    Lively Member Professor29's Avatar
    Join Date
    Feb 2002
    Posts
    89
    Try putting vbCode in braces (ex:[]) at the beginngin of the code and /vbCode in braces at the end of the code.

    Instead of this:

    If bla then 'My Code

    Or this with code tags:

    Code:
     If bla then 'MyCode
    Your code will look like this:

    VB Code:
    1. If bla then 'MyCode

    Try that.
    ERROR: No keyboard detected. Hit F1 to continue.

  9. #9
    Frenzied Member andreys's Avatar
    Join Date
    Sep 2002
    Location
    Los Angeles
    Posts
    1,615
    Ye that... Thanks Mc Brain

  10. #10
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Originally posted by fasi
    Thanx,

    But can you guys see now why is it giving me this error
    Sorry... I've only worked with Crystal Reports a few times and don't remember anything. That's why a proper subject is important!!!
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  11. #11
    Frenzied Member andreys's Avatar
    Join Date
    Sep 2002
    Location
    Los Angeles
    Posts
    1,615
    On what line are you getting an error?

  12. #12

    Thread Starter
    Hyperactive Member fasi's Avatar
    Join Date
    Nov 2000
    Posts
    474
    the last line where

    report.printout false

  13. #13
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Here's an importaint question: What's the error? <snip> -- ignore this part -- And specify EXACTLY what line it is giving an error on....</snip>
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  14. #14
    Frenzied Member andreys's Avatar
    Join Date
    Sep 2002
    Location
    Los Angeles
    Posts
    1,615
    If you using Crystal Report Control, there is no such thing as .PrintOut

    try

    VB Code:
    1. Report.PrintReport

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