Solved

Crystal Report from Data Control

Posted on 1998-12-03
4
224 Views
Last Modified: 2013-12-25
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
Comment
Question by:AlanMarsham
  • 3
4 Comments
 
LVL 2

Expert Comment

by:cedricd
ID: 1488672
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
 
LVL 2

Expert Comment

by:cedricd
ID: 1488673
Don't forget to link the datacontrol with crystal report control !
0
 

Author Comment

by:AlanMarsham
ID: 1488674
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
 
LVL 2

Accepted Solution

by:
cedricd earned 100 total points
ID: 1488675
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MS Date Picker 64 bit 32 bit issue 12 60
Add a task in Outlook from access 11 42
Convert VB6 MSXML2.ServerXMLHTTP process to C# 2 58
Visual Studio 2005 text editor 10 44
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

856 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