Link to home
Start Free TrialLog in
Avatar of AlanMarsham
AlanMarsham

asked on

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...
Avatar of cedricd
cedricd

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
Don't forget to link the datacontrol with crystal report control !
Avatar of AlanMarsham

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of cedricd
cedricd

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