Solved

Crystal Report from Data Control

Posted on 1998-12-03
4
219 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 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

26 Experts available now in Live!

Get 1:1 Help Now