Good Day People

I'v just finished my project in VB6.0 and now have to include reports for the program. I would like a button in VB6.0 to direct to a report in crystal report V85. I'm just not sure how the code on the button is supposed to be.
Could someone please help.
Thanks.

temytope commented: I WANT TO DESIGN A POINT OF SALES SOFTWARE IN VB. CAN SOMEONE HELP ME OUT?THANKS +0

You must reference your Crystal Report v.(whatever Version) in vb6. (Project, References)

In your code window add the following -

crstlYourReportName.ReportFileName = Path & "\Your Report Name.rpt" 'Path will be the path where your report has been saved.

crstlYourReportName.PrintReport 'If you want to print it immediatly

You must reference your Crystal Report v.(whatever Version) in vb6. (Project, References)

In your code window add the following -

crstlYourReportName.ReportFileName = Path & "\Your Report Name.rpt" 'Path will be the path where your report has been saved.

crstlYourReportName.PrintReport 'If you want to print it immediatly

I have referenced the crystal report, and this is how my code looks like:Dim op_stock As Report

op_stock.opening = Path & "C:\reports\opening.rpt"

but at run-time at give an error saying: Object variable or with block variable not set.

Please help.

Look at my sample above. Your code should look like this -

op_stock.ReportFileName = "C:\reports\opening.rpt"

Look at my sample above. Your code should look like this -

op_stock.ReportFileName = "C:\reports\opening.rpt"

Hi There

I'v used the code above, but it's still giving me the same error saying: object variable or with block not set.

Which version and make (Report viewer, SDK etc.) of Crystal Reports are you using?

Which version and make (Report viewer, SDK etc.) of Crystal Reports are you using?

Hi
I'm using crystal reports for ACCPAC advantage series.
I don't know if I've provided the right information, but please do mention, if this does'nt cater for your needs.
Please help
Thanks.

maybe you forgot to SET it in your declaration....

just maybe.... LoL

The object or with block variable normally refers to the data connection not referred in your code. This means that whilst you are trying to open the report (which gets its data from a database), there is no connection to show data on your report. Make sure that your report setup is 100% correct. I presume that you have build your report from the crystal reports IDE. I'm not sure how ACCPAC performs, but try the following links. They might have an answer for you to confirm your connection. The connection string above was used by myself in 3 different Crystal Report versions, and they all work fine. MAKE SURE THAT CRYSTAL REPORTS IS REFERENCED IN YOUR PROJECT. Click on 'Project, References' and add the Crystal Report Library references as well.

http://www.pcginc.com/tipsandtricks.asp
http://www.etbsolutions.com/library/accpac/Passing_parameters_to_Crystal.pdf (This looks like the best of all the links. It seems you must setup the .ini file as well.)
http://www.google.co.za/search?hl=en&rlz=1T4WZPA_en___ZA340&q=crystal+reports+for+ACCPAC+vb6&start=10&sa=N

Hope this gets you closer to solving your problem.

maybe you forgot to SET it in your declaration....

just maybe.... LoL

The thing is that it's my first time using crystal reports, so I'm new in this thing, how do you set it. my code looks like this:
Dim op_stock As Report

op_stock.ReportFileName = "C:\Documents and Settings\andilem\Desktop\eco\Report1.rpt"

What is short.
Please help.
Thanks.

'In your general decleration add the following
Private WithEvents op_Stock AS CrystalReport.Report 'I'm not sure what the CrystalReport will show in your case. Select it from the list given that pops up after you have typed AS. After you have made your selection, press '.' and another list will show. Select report or similar from list. Now add your code - 
Set op_Stock = New CrystalReport.Report 'Refer to the above comment.
op_stock.ReportFileName = "C:\Documents and Settings\andilem\Desktop\eco\Report1.rpt"

op_Stock.Show 'Again i'm not sure Show is the correct syntax, but it will be similar from the list.
'In your general decleration add the following
Private WithEvents op_Stock AS CrystalReport.Report 'I'm not sure what the CrystalReport will show in your case. Select it from the list given that pops up after you have typed AS. After you have made your selection, press '.' and another list will show. Select report or similar from list. Now add your code - 
Set op_Stock = New CrystalReport.Report 'Refer to the above comment.
op_stock.ReportFileName = "C:\Documents and Settings\andilem\Desktop\eco\Report1.rpt"

op_Stock.Show 'Again i'm not sure Show is the correct syntax, but it will be similar from the list.

I'v used the above code, and it gives me an error saying: Invalid attribute in sub or function. I'v tried all the options, after As when declaring.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.