Solved

Dynamic Crystal Report 8.0 with VB 6.0

Posted on 2004-09-30
15
1,085 Views
Last Modified: 2007-12-19
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
0
Comment
Question by:musalman
  • 8
  • 6
15 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 12192714
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
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 12192791
0
 
LVL 4

Author Comment

by:musalman
ID: 12204832
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
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 100 total points
ID: 12205972
WIth a 1 to many relationship there are 2 ways to solve this.
You found one using a subreport.  The other method is through groups.
Link the subreport to the main report  on the common field.
Open the report
Select the subreport
Right Click --> CHANGE SUBREPORT LINKS

Create a group in the report
Field to group on - The common or linking field in the 1 to many relationship
Put the common (repeted) information in the groupheader
Put the details in the details section for the group.

mlmcc
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 12429974
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
0
 
LVL 4

Author Comment

by:musalman
ID: 12449064
DEar mlmcc

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

Author Comment

by:musalman
ID: 12449845
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...
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 100

Expert Comment

by:mlmcc
ID: 12450172
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
0
 
LVL 4

Author Comment

by:musalman
ID: 12458268
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
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 12460366
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
0
 
LVL 4

Author Comment

by:musalman
ID: 12520458
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>
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 12520792
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
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 12530237
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
0
 
LVL 4

Author Comment

by:musalman
ID: 12570081
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 ???
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now