Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering Records To Be Printed Using VB6 and Crystal Reports 8

Status
Not open for further replies.

sonper

Programmer
Oct 4, 2001
94
PH
Hi! Can anybody tell me what's wrong with these codes? I am a newbie in Crystal Report and this is my first project. I want to produce a report based on the SQL statement that I make. Is there something wrong with the way I connect my database with the report? Also can you tell me what is the reference or dll file that makes this command work:

Dim Report as New CrystalReport1



I'm using VB6, MS Access and Crystal Report 8

Here are the codes:

Option Explicit
Private conn as ADODB.connection
Private rs As ADODB.Recordset
Public rephead As String
Dim SQL As String

Private Sub cmdPrint_Click()
SQL = &quot;{tblReso1.ApprovDate} >= #&quot; & mskPrintDate1.Text & &quot;# And {tblReso1.ApprovDate} <= #&quot; & mskPrintDate2.Text & &quot;# order by ResoNum&quot;
rephead = &quot;RESOLUTIONS PASSED FROM &quot; & Format(mskPrintDate1.Text, &quot;mmmm dd, yyyy&quot;) & &quot; TO &quot; & Format(mskPrintDate2.Text, &quot;mmmm dd, yyyy&quot;)
With CrystalReport1
.ReportFileName = App.Path & &quot;\reso.rpt&quot;
.ReplaceSelectionFormula (&quot;SQL&quot;)
.Formulas(0) = &quot;header = '&quot; & rephead & &quot;'&quot;
.PrintReport
End With
End Sub


Private Sub Form_Load()
Set conn = New ADODB.Connection
conn.Open &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\sp\sp.mdb;Persist Security Info=False&quot;
mskPrintDate1.Mask = &quot;##/##/####&quot;
mskPrintDate2.Mask = &quot;##/##/####&quot;
mskPrintDate1.Text = Format(Date, &quot;mm/dd/yyyy&quot;)
mskPrintDate2.Text = Format(Date, &quot;mm/dd/yyyy&quot;)

End Sub

Please help!
 
What CR components or refernces are you currently using to integrate CR?

Do you have the developers edition of CR? Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Hi sir! I'm not sure about my answer to your question but I have these references and component in my VB6:

References:
CRDatasource 1.0 Type Library
Crystal Data Object
Crystal Report 8 Active X Designer Run Time Library
Crystal Report 8 Standard Wizard Library
Crystal Report Viewer Control

Component:
Crystal Report Control (crystl32.ocx)

I am using Crystal Report 8 Professional Edition
 
None of these components/references come with the professional edition. You need the developer's edition of CR to integrate with VB.

Then you have to decide which of the 4 integration methods to use. You seem be using parts of 2 different methods. The OCX and the RDC. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Now I know why I'm having a hard time figuring it out! But one last thing sir, did I use the right syntax in my SQL statement? And how am I going to call it in VB to produce the desired report based on the SQL statement? Or this can be done in CR.

SQL = &quot;{tblReso1.ApprovDate} >= #&quot; & mskPrintDate1.Text & &quot;# And {tblReso1.ApprovDate} <= #&quot; & mskPrintDate2.Text & &quot;# order by ResoNum&quot;
rephead = &quot;RESOLUTIONS PASSED FROM &quot; & Format(mskPrintDate1.Text, &quot;mmmm dd, yyyy&quot;) & &quot; TO &quot; & Format(mskPrintDate2.Text, &quot;mmmm dd, yyyy&quot;)
With CrystalReport1
.ReportFileName = App.Path & &quot;\reso.rpt&quot;
.ReplaceSelectionFormula (&quot;SQL&quot;)
.Formulas(0) = &quot;header = '&quot; & rephead & &quot;'&quot;
.PrintReport
End With
 
All syntax depends on which Integration method you plan on using. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
I'm not sure about the integration thing. But suppose I use VB6 to call on my CR(connected to MS Access DB) how am I going to code it.
 
That is too broad a question, since there are 4 different ways to code it, depending on which integration method you are using.

If you need a broad overview of the options, there are several sources. Crystal's web site has information and sample applications and there is a developer's guide that comes with CR developer edition. There are also 3rd party books, including my own, that give an overview of the available techniques with sample code. Another popular one is by George Peck.

Good Luck. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top