|
-
Oct 13th, 2004, 02:00 AM
#1
Thread Starter
Addicted Member
Display variable value in Crystal Report Text Box
In my application I have certain calculated values stored in variables. I am using Visual Basic 6 and Crystal Reports 8.5 and my Report has certain Text Boxes where I want to display the calculated values. I don't want to use the Data Fields. I want to do like this:
Code:
Dim C as ...CrystalReport1
Dim var1, var2 As String
Set C = New CrystalReport1
C.txtName.Text = var1
C.txtNumber.Text = var2
But the Crystal Report displays an error at lines "C.txtName", saying that it is a Read-Only field.
-
Oct 13th, 2004, 07:34 AM
#2
PowerPoster
Why not use parameters? such as;
Set the fields as parameters on your report . Then in your code..
Report.ParameterFields.Item(1).AddCurrentValue var1
Report.ParameterFields.Item(2).AddCurrentValue var2
I am using CR9.5, so the syntax may vary slightly.
-
Oct 13th, 2004, 12:41 PM
#3
Thread Starter
Addicted Member
I tried this, and this command style is available in 8.5 also. But as I call the report from VB (runtime), Crystal Report displays a dialog box to enter the parameter value. But I want the variable value to be automatically transferred to the parameters and the report should start printing.
-
Oct 14th, 2004, 07:07 AM
#4
PowerPoster
It shouldn't ask you for the value if you run it from within your VB app. If you supply the values when you run the report, it works fine (for me). Example:
Set Report = crxApplication.OpenReport("Z:\DAD\ShipvsProd.rpt", 1)
For Each crxDatabaseTable In Report.Database.Tables
crxDatabaseTable.ConnectionProperties("user id") = "sa"
crxDatabaseTable.ConnectionProperties("Password") = myPasswordTechniSQL
Next crxDatabaseTable
Report.SelectPrinter glbPrinterDriver, glbPrinterName, glbPrinterPort
Report.PaperOrientation = crDefaultPaperOrientation
Report.ParameterFields.Item(1).AddCurrentValue glbDate
Report.ParameterFields.Item(2).AddCurrentValue glbDate1
If glbPrinterDestination = 0 Then
glbReportForm = "frmProduction"
CRViewer.Show vbModal
Else
Report.PrintOut False
End If
-
Oct 15th, 2004, 04:18 AM
#5
Hyperactive Member
Guy,
If i have created 1 Crystal report, how can i use that report
using App.Path.
I mean i want to use that like this REPORT.SOURCE
(or something i dont know ) = App.Path & "\TEST.RPT"
Thanks
The only easy day was yesterday
-
Oct 15th, 2004, 12:50 PM
#6
VB Code:
Option Explicit
'Add reference to -
'Crystal Data Object
'Crystal Reports x.x Library
'Crystal Reports x.x ActiveX Designer Runtime Library
Private oReport As CRAXDRT.Report
Private crxApp As CRAXDRT.Application
Private Sub Command1_Click()
Set crxApp = New CRAXDRT.Application
Set oReport = New CRAXDRT.Report
Set moReport = crxApp.OpenReport(App.Path & "\TEST.rpt", 1)
'...
'...
'...
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 17th, 2004, 10:19 PM
#7
Hyperactive Member
Thanks a lot man
The only easy day was yesterday
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
|