|
-
Jul 10th, 2006, 09:17 AM
#1
Thread Starter
Fanatic Member
VB6 with CR9
Hi
I have a listbox that contains up to 20 items.I want to write each item into a crystal report 9 report
The code I will be using is:
VB Code:
For i=0 to lstitems.listcount-1
slist=lstitems.list(i)
...'here I want to add the slist into CR9
...'here's the rest of my code
Next i
Can anyone help me because i'm new to CR9.
thanks in advance
-
Jul 10th, 2006, 10:04 AM
#2
PowerPoster
Re: VB6 with CR9
You have a couple options.
1) you can call the report using a "select- like" statement:
VB Code:
Report.RecordSelectionFormula = "{DestroyAuth.SEQ} = " & CLng(lblSequence.Caption)
2) you add a parameter to the report and pass the parameter value:
VB Code:
Report.ParameterFields.Item(1).AddCurrentValue cust
-
Jul 10th, 2006, 11:59 AM
#3
Re: VB6 with CR9
You can also use an ADO recordset for the DataSource of the report and in preparing it you can use your list items to build a sql select statement as your recordset source.
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 
-
Jul 11th, 2006, 02:29 AM
#4
Thread Starter
Fanatic Member
Re: VB6 with CR9
I tried
VB Code:
For i=0 to list1.list(i)
Report.ParameterFields.Item(1).AddCurrentValue list1.list(i)
Next i
It returned to me:
"Script out of range"
What's wrong?
Thanks
-
Jul 11th, 2006, 06:45 PM
#5
Re: VB6 with CR9
You need to .Add a parameter first before you can reference it.
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 
-
Jul 12th, 2006, 02:01 AM
#6
Thread Starter
Fanatic Member
Re: VB6 with CR9
RobDog888,I used ur example of VB6/Crystal Report present in your signature in order to display a recordset,what i want also is to display the content of a listbox in the report footer,so I added a parameter to the report and place it in the page footer(When creating the parameter i entered its name and type and I checked discrete value).When I execute the following code:
VB Code:
Rs.Open str2, cnn, adOpenStatic, adLockOptimistic
Set oApp = New CRAXDRT.Application
Set oReport = oApp.OpenReport(App.Path & "\Report2.rpt", 1)
For l = 0 To List1.List(l)
oReport.ParameterFields.Item(1).AddCurrentValue List1.List(l)
Next l
oReport.Database.SetDataSource Rs, 3, 1
crvMyCRViewer.ReportSource = oReport
crvMyCRViewer.ViewReport
crvMyCRViewer.Refresh
Rs.Close
End Sub
It returned to me "Type mismatch" and it highlighted the For loop.
So I removed the For loop and I replaced it by:
oReport.ParameterFields.Item(1).AddCurrentValue List1.List(0)
the code prompted me to enter a discrete value of the parameter,I entered a string and It was added to the report's footer.
How should I create the parameter?discrete value,range value or ...
and what's wrong with the for loop?
Thanks in advance
-
Jul 12th, 2006, 12:00 PM
#7
Re: VB6 with CR9
Did you make it a Text/String type in CR? If its a footer then your only placing in one parameter so why the loop? You should always .Clear before you .Add the parameter value.
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 
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
|