Link to home
Start Free TrialLog in
Avatar of musalman
musalmanFlag for Oman

asked on

Dynamic Crystal Report 8.0 with VB 6.0

Hi,
Problem : I m using Crystal Report 8.0 with VB 6.0.  I made a Report using Report wizard. Thats Ok...
But I want to run it through VB 6.0 as I have to Pass more then 1 parameters.

My question: How will we do it ? As My report is working but if I pass SQLquery from VB and give a SelectionFormula Also, It does not show any ... If , I omit the SQL query from VB and then pass only Selection Formula, It works...but doen not refresh the Report contents and show only Old Records.

My question is getting Long, so plz in short Just tell me the Simplest Way to Create a Dynamic Report that I can Open using VB with some more then 1 parameters.

Thanks
Yasir Aziz
Karachi, Pakistan
Avatar of Mike McCracken
Mike McCracken

First  check if the report has saved data

Open the report
Click FILE
 Ensure SAVE DATA WITH REPORT is not checked

What method are you using to call the report?  RDC or OCX?

mlmcc
Avatar of musalman

ASKER

Dear mlmcc ...

Your First reply solved my First Question i.e Refreshing data... Many thanks ...

But still I am Confused as I saw that I have CR 7.0  installed...

Moreover I have one more situation... As an Example, 1 order has many Order details... If we display that order with its detail. what happens that Order Fields repeat with Order Detail Fields.

I came to know that it may solve using Sub Report...I designed SubReport and Put on Main report but I dont know how will it relate to Main Report ...

I am using OCX method...

Thanks
Yasir Aziz
Karachi, Pakistan
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
My comments should have solved the problem.  As his last comment says I solved the first problem.  My next comment should have resolved or allowed him to resolve the 1 to many problem.

mlmcc
DEar mlmcc

Finally tell me that If i want to avoid sub reports then is Grouping another solution for 1 to many Relation ship ???
Dear mlmcc

And some thing more that...

I have different criterias to view a report... like By City , By City and Time both, By Customer etc...

Tell me do I make separate reports for all these criterias or There is any good solution that I design One report only and Filter records depending on my need...

I used CRP.Selectionformula......... It works for one criteria but for 2 or more criterias, I fail to write the correct syntax...

Finally sorry that I lately accepted your Reply as I had not Internet facility at home...
No problem.

Since you are using the OCX.

Don't pass it a query use the query the report was built against.  

Use
crp.ReplaceSelectionFormula "{table.City} = 'MyCity' AND {Table.Date} = #10/13/2004#"

I'll try to find the code to build it from a VB form.  I have it but not readily available.

Grouping vs subreports
In my mind the 2 are used for different purposes
Groups take the existing data and sort it by a field so it can be grouped by that field.
You use the group header for the common information and the detail section for the varying information.
Example Students and grades
Group by student identifier
Header has
  Identifier, Name, Age, address, etc
Details has
  Class name, scores, and grade
Group footer might have
  Current standing, GPA, number of credits earned, etc

Subreports are used to combine data sources that are otherwise difficult to combine or that may be from different data sources or databases.
Subreports get linked to the main report by a common field to ensure the subreport shows the data related to the main report record.

In the example I used it could be done with subreports if so desired.

mlmcc
Here I used your syntax but VB Generated Error about Sysntax Problem.

ReplaceSelectionFormula "{tblATMHost.BranchName}= 'cboBranch' AND {tblHostATMProblem.curDate} between  #DTPicker1.Value# AND #DTPicker2.Value#"

Please check this sysntax and tell  me the correct one if it is Wrong.

Thanks
You need to use the report object.  Also the date picker values need to be evaluated by VB so they need to be out side the " ".  The same with the other VB drop down.

crRpt.ReplaceSelectionFormula "{tblATMHost.BranchName}= '" & cboBranch & "' AND {tblHostATMProblem.curDate} between  #" & cstr(DTPicker1.Value) & "# AND #" & cstr(DTPicker2.Value) & "#"

mlmcc
Dear mlmcc...

I m still facing Error message when I only Pass  single date Like

            .SelectionFormula = "{qryHostLogReport.curDate} <= #" & CStr(DTPicker1.Value) & "#"
            .WindowState = crptMaximized
            .Action = 1

============================================
Runtime Error '20515'

A number, currency amount, boolean or string is expected here.
============================================

I am afraid that is there any Problem in Report or Still in code.

If i do not pass any parameter , Report is Fine and shows all contents quickly.

Dear mlmcc, Send me a  report , VB Code, and a single Access Table , If you can...

I shall be very thankful to you...

<email deleted by mlmcc PE>
EMail contact for the purpose of solving problems is not allowed by the EE membership guidelines.

The only access samples I have are the same ones you have on the Crystal CD.

Are you sure the date field is a date data type?

I'll find my OCX sample code and attach it later.

mlmcc
I didn't use the date picker but a different calendar control but here is the difference

.SelectionFormula = "{qryHostLogReport.curDate} <= #" & DTPicker1.text & "#"

or

.SelectionFormula = "{qryHostLogReport.curDate} <= #" & DTPicker1.Value & "#"

mlmcc
Yes , At Last I Succeeded.

What was wrong Acrtually the Crystal Report Version . As I told you  that I had CR 7.0 But when I designed the report on CR 8.0 and Exceuted the Code , Problem resolved...

Aaah, My 10 days went to hell as i was Trying  n Trying.

Many Thanks mlmcc...
May I ask your Name and Country and more about you ???