VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This code snippet helps u in creating crystal reports, without writing the often repeating lines. J

by KsanDOESFORU (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 12th March 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This code snippet helps u in creating crystal reports, without writing the often repeating lines. Just include it in module, get a crviewer

API Declarations


add a crystal report to project


Rate This code snippet helps u in creating crystal reports, without writing the often repeating lines. J



'1. first create a form by any name you like
'2. insert a crViewer control (it is a crystal report control)
 'and name it crViewer. This name is generally by default.
'3. While Calling the parameter would be
'   a.The name of the form which contains the crViewer control
'   b.Title of Report which is optional
'   c.Record selection formula which is optional
'4. The setloginfo property of the cReport Changes according to the
'server which you are connecting, so set it accordingly
'5. To make report dynamic set the location of the server
'6. include it project as module
Public cReport As CRAXDRT.Report
Public Sub PrintReport(ByRef frmPrintPreview As Form, Optional ByVal ReportTitle As String, Optional ByVal strCondition As String)
     Dim iCtr As Integer
       For iCtr = 1 To cReport.Database.Tables.count
            cReport.Database.Tables(iCtr).SetLogOnInfo "The name of Server", "Name of database", "<Username>","<password if any>"
            cReport.Database.Tables(iCtr).Location = "Nameofdatabase.Owner(for ex:dbo)." & cReport.Database.Tables(iCtr).Name
        Next
        If Len(ReportTitle) > 0 Then cReport.ReportTitle = ReportTitle
        If Len(strCondition) > 0 Then cReport.RecordSelectionFormula = strCondition
        frmPrintPreview.CRViewer.Zoom (100)
        frmPrintPreview.CRViewer.ReportSource = cReport
        frmPrintPreview.CRViewer.ViewReport
        frmPrintPreview.Refresh
        
        If frmPrintPreview.Visible = False Then frmPrintPreview.Show vbModal
        
End Sub

' call this function before calling the PrintReport 

Public Sub setReport(ByRef RepoName As Report, ByVal printname As Boolean)
        Set cReport = RepoName
        If printlotname = True Then RepoName.<labelname on report>.SetText UCase(<the text u want to insert>)
End Sub


Download this snippet    Add to My Saved Code

This code snippet helps u in creating crystal reports, without writing the often repeating lines. J Comments

No comments have been posted about This code snippet helps u in creating crystal reports, without writing the often repeating lines. J. Why not be the first to post a comment about This code snippet helps u in creating crystal reports, without writing the often repeating lines. J.

Post your comment

Subject:
Message:
0/1000 characters