|
-
Oct 7th, 2006, 08:16 AM
#1
Thread Starter
Just Married
Crystal Report In VB
Hi all
Often user get problem when they make setup of the VB project using the crystal report.
Report will be not display at the other Pc where crystal report is not installing.
1) How to use the crystal report
Make the report it is batter fro you that you make it using the DSN with the database.
For making the run time DSN you can use the code given by me in the VB
Code Bank in the General problem for the new user, See my Signature.
Open the Project Add the crystal report control
Right click on this control and set the property.
Report for the string value in the database
VB Code:
Private Sub Command1_Click()
'Report With String
Dim S As String
S = "{Table.Field}='" & Text1.Text1 & "'"
With CrystalReport1
.ReportFileName = App.Path & "\ReportName.rpt"
.SelectionFormula S
.Action = 1 'Will Show The Report
End With
End Sub
Report for the integer value in the database
VB Code:
Private Sub Command1_Click()
'Report With Number
Dim S As String
S = "{Table.Field}=" & Text1.Text1 & ""
With CrystalReport1
.ReportFileName = App.Path & "\ReportName.rpt"
.SelectionFormula S
.Action = 1 'Will Show The Report
End With
End Sub
Report when there is mix of number and the integer in the condition
VB Code:
Private Sub Command1_Click()
'Report With Number and string
Dim S As String
S = "{Table.Field}=" & Text1.Text1 & " and {Table.Field}='" & Combo1.Text & "'"
With CrystalReport1
.ReportFileName = App.Path & "\ReportName.rpt"
.SelectionFormula S
.Action = 1 'Will Show The Report
End With
End Sub
For removing the error at the client Pc add the Dll database.dll, crystal32.ocx,p2sodbc.dll
You can change the selection formula according to above condition
Here table is the TableName
Field is the Table Field
Report Is the Crystal Report Name
Last edited by shakti5385; Oct 7th, 2006 at 08:21 AM.
Reason: Add VBCODE
-
Oct 7th, 2006, 08:39 AM
#2
Thread Starter
Just Married
Re: Crystal Report In VB
When There is need to find the report between two date
VB Code:
Private Sub Command1_Click()
'Report Between Two Date
Dim S As String
S = "{Table.DateField}>=date( " & DTPicker1.Year & "," & DTPicker1.Month & "," & DTPicker1.Day & ") And {Table.DateField}<= date(" & DTPicker2.Year & "," & DTPicker2.Month & "," & DTPicker2.Day & ")"
With CrystalReport1
.ReportFileName = App.Path & "\ReportName.rpt"
.SelectionFormula S
.Action = 1 'Will Show The Report
End With
End Sub
-
Oct 9th, 2006, 07:24 AM
#3
Thread Starter
Just Married
Re: Crystal Report In VB
Using the selection formula we have one more option for searching the report using our condition, this option is call SQL query option using this option you are able to pass your query in the report and the report will show the selected data using the query. SQL selection query example is given below.
Here table is the table name and field is the field in the table. You can change the Query according to the condition.
Here for sorting the data you can also use the order by clause.
See the Example.
VB Code:
Private Sub Command1_Click()
Dim S As String
S = "Select * from Table where field='" & Text1.Text & "' Order By ID"
With CrystalReport1
.ReportFileName = App.Path & "\ReportName.rpt"
.SQLQuery = S
.Action = 1
[B]MsgBox .RecordsPrinted 'For Total number of record[/B]
End With
End Sub
Last edited by shakti5385; Oct 9th, 2006 at 09:13 AM.
-
Feb 5th, 2007, 09:44 AM
#4
New Member
Re: Crystal Report In VB
sir, this is my code in VB6 crustal reports XI
Private Sub Form_Load()
Dim crxApp As New CRAXDDRT.Application
Dim crxReport As CRAXDDRT.Report
Dim ReportName As String
ReportName = App.Path & "\report1.rpt"
Set crxReport = crxApp.OpenReport(ReportName)
CRV1.ReportSource = crxReport
Dim S As String
' i want to view only transactions under CustSaleNo = 1. don't have selectionFormula Method/Property
S = "{CustomerInvDetails.CustSaleNo} <> '1'"
crxReport.RecordSelectionFormula = S <----error here "A number is required in here"
CRV1.ViewReport
End Sub
-
Feb 6th, 2007, 04:46 AM
#5
New Member
Re: Crystal Report In VB
fix my error... there should be no ' '...it should only be 1 without the ' "
-
Mar 15th, 2007, 07:13 AM
#6
Thread Starter
Just Married
Re: Crystal Report In VB
 Originally Posted by eureka8888
fix my error... there should be no ' '...it should only be 1 without the ' "
Post this problem in the reporting section, not in the tutorial.
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|