• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

Crystal Report from Data Control

I have a data control recordset with a crystal report control bound to it.  When I action the report I only see the first 3 or 4 columns on the preview and I have no way of programatically altering the size and headings of the columns.  This recordset may very well contain records from other tables or data sources and the report will be used as a general "dump to printer" or "dump to file" option.  Any help from anyone would be most appreciated...
0
AlanMarsham
Asked:
AlanMarsham
  • 3
1 Solution
 
cedricdCommented:
i will explain how i use the crystal report, maybe will you find the solution on it.
first i make a sql query linked to a data control.
in my sql query, i select all the field i need for my report (also in another table)

example : select a.*, b.* from tablea as a,tableb as b where ...

when my query is executed by the datacontrol, i print a crystal report into a file

code :

       Crystal.SQLQuery = sql
       Crystal.ReportSource = crptDataControl
       Crystal.PrintFileType = crptCrystal
       Crystal.PrintFileName = App.Path + "\Reports\" + Fichier
       Crystal.ReportFileName = App.Path + "\Reports\" + Fichier
       Crystal.Destination = crpttofile
       Crystal.PrintReport
After, i open the report created and i modify the layout (maybe where's too many field, you had to insert manually them choose insert menu database field and you can insert all the bound control field)
you can modify the properties of the crystal field (format,border etc..)

when it's done,print the crytal to the window (to verify if it's correct) and to the printer if it's good

       Crystal.SQLQuery = sql
       Crystal.ReportSource = crptReport
       Crystal.PrintFileType = crptCrystal
       Crystal.PrintFileName = App.Path + "\Reports\" + Fichier
       Crystal.ReportFileName = App.Path + "\Reports\" + Fichier
       Crystal.Destination = crptto(window or printer)
       Crystal.PrintReport

the sql command must be with same field but you can change the table name, the db name and their place.The fields must be the same (with the same order)

hope i help you.
                CD
0
 
cedricdCommented:
Don't forget to link the datacontrol with crystal report control !
0
 
AlanMarshamAuthor Commented:
From my user's point of view this is too complicated - I don't mind how complicated it is to program but it has to be relatively user friendly to use.  Besides, my customers normally don't have a copy of Crystal Reports so they can't adjust the layout of the report.

Could really do with a "run report and fit to x pages wide" option which automatically picks all columns in the attached data source.
0
 
cedricdCommented:
if your customer had to modify the layout, he won't be able to do it without crystal report,with crystal report there's only two maniers to make a report : one use the crystal report program to make a report linked to a database, second with the code i past to you.
a report is always linked to a sql statement (select * from table or a more complicated sql statement).
The number of columns are defined by the sql statement or by you using crystal report.
When the number of select field change then you had to make a new report (maybe a solution is to select all the possible field into a temporaly table, adding a logical field which is true when you had to print the field and in crystal report for each field program a formule like if {bound control.logicfield} then {bound control.field1}
and to make yourself a layout.
the temporaly table can be an access table.
you can program the page header (new page after, before etc..)
it's all you can do with crytal for you problem.
Maybe if you explain more better the program you had to make,i will be able to propose you the best solution.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now