Solved

Crystal Report 11 Design advise

Posted on 2009-05-08
16
219 Views
Last Modified: 2012-05-07
Hello Experts,

I am generating crystal report by passing through the dynamic data source at the run time.

I now have a situation where I have to print 20 questions and mulitple choice options to the report.

I am unable to decide whether I should design the crystal report with 20 label controls for the questions to print and 80 label control for the options?

Ideally I would like to 1 label for the questions and 4 label for the options and loop through I am not having any clue how to achieve this from the code I have at the moment.

Please can someone assist me here?

Thanks
S
0
Comment
Question by:newbie27
  • 9
  • 7
16 Comments
 
LVL 8

Author Comment

by:newbie27
ID: 24335060
please see the buldgiftcodetable function attached below..

on the report i have got 3 columns at the moment ie: giftcodeid, expirydate and testname

in order to show the 20 questions and mulitple choice options to the report, do i need to have those many columns on the report?

i am bit confused here, i hope someone may understand and advise me a solution here..


thanks
s
'Create the codes in a dataset
 ds = BuildGiftCodeTable(TypeID, NumCodes, GiftTypeID)
 ExportAsPDF(ds, ReportFileName, ExportFile)
 
 
Private Function BuildGiftCodeTable(ByVal GiftCodeType As String, ByVal NumCodes As Integer, ByVal GiftTypeID As WebFunctions.GiftType) As DataSet
        Dim ds As New DataSet("GiftCodes")
        Dim dt As DataTable
        Dim dr As DataRow
        Dim CodeStart, GiftCodeID As String
        Const GiftCodeIDLength As Integer = 14
        Dim CodeLength As Integer
        Dim ExitLoop As Boolean = True
        Dim MasterOfArtTestID As Integer
 
        'define the structure of the table
        dt = New DataTable("GiftCode")
        dt.Columns.Add("GiftCodeID")
        dt.Columns.Add("ExpiryDate")
 
        'Add columns for STAR codes
         
            'Get the first characters of the code
            CodeStart = GiftCertificateTypeBLL.GetTypeGiftCode(GiftCodeType)
 
            'Create a gift code for each number of codes to be created
            For i As Integer = 1 To NumCodes
                Do
                    CodeLength = GiftCodeIDLength - Len(CodeStart)
                    GiftCodeID = CodeStart & GenerateGiftCode(CodeLength)
 
                    'Check whether the GiftCodeID already exists
                    ExitLoop = True
                    If GiftCertificateBLL.GetGiftCertificate(GiftCodeID).Rows.Count = 0 Then
                        'Search the codes that were just created
                        For Each Row As DataRow In dt.Rows
                            If GiftCodeID = Row.Item("GiftCodeID") Then
                                ExitLoop = False
                            End If
                        Next
                        If ExitLoop Then
                            Exit Do
                        End If
                    End If
                Loop
 
                dr = dt.NewRow
                dr.Item("GiftCodeID") = GiftCodeID
                dr.Item("ExpiryDate") = GetExpiryDate(WebFunctions.GiftType.NameAStar)
                'Dim GiftTypeID As String = "CHOCOLATE"
 
                If GiftTypeID = WebFunctions.GiftType.MasterTheArtOf Then
                    dt.Columns.Add("TestName")
                    dr.Item("TestName") = LearnItClass.GetTestName(GiftCodeID)
                    MasterOfArtTestID = LearnItClass.GetTestID(GiftCodeID)
 
                    'To get random questions 
                    Dim MasterTheArtOfClass As New MasterTheArtOf
                    Dim dsQ As DataSet = MasterTheArtOfClass.GetRandomQuestions(MasterOfArtTestID)
                    'dsQ = obj.GetRandomQuestions("1")
                    Dim order As Integer
                    order = 1
                    For Each row As DataRow In dsQ.Tables(0).Rows
                        ' Storing the questions in the separate table to concieve the questions order
                        MasterTheArtOfClass.AddTestQuestionPapers(GiftCodeID, "1", row("questionid"), order)
                        order = order + 1
                    Next
 
 
 
        End If
                dt.Rows.Add(dr)
            Next
 
        End If
 
        'add the table to the dataset
        ds.Tables.Add(dt)
       
        Return ds
    End Function
 
 
 
 Public Shared Function ExportAsPDF(ByVal ds As DataSet, ByVal ReportFileName As String, ByVal ExportFile As String) As Boolean
        Dim crReportDocument As New ReportDocument
        Dim crExportOptions As ExportOptions
        Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
        Dim GRFiles, ReportFilesDirectory As String
 
        Try
            'create new report documents
            GRFiles = ConfigurationManager.AppSettings("GRFiles")
            ReportFilesDirectory = ConfigurationManager.AppSettings("ReportFilesDirectory")
            crReportDocument.FileName = GRFiles & ReportFilesDirectory & ReportFileName
            crReportDocument.SetDataSource(ds)
 
            'set the export location
            crDiskFileDestinationOptions = New DiskFileDestinationOptions()
            crExportOptions = crReportDocument.ExportOptions
            crDiskFileDestinationOptions.DiskFileName = ExportFile
 
            'set the required report ExportOptions properties
            With crExportOptions
                .DestinationOptions = crDiskFileDestinationOptions
                .ExportDestinationType = ExportDestinationType.DiskFile
                .ExportFormatType = ExportFormatType.PortableDocFormat
            End With
            ' Export the report
            crReportDocument.Export()
        Catch ex As Exception
            SendEmail(ex.ToString)
            Return False
        End Try
 
        Return True
    End Function

Open in new window

0
 
LVL 100

Expert Comment

by:mlmcc
ID: 24341447
SInce you are putting the data in tables just use them for the report

Group by question number
In the group header put the question
in the details put the answer choice

You will get 1 detail section for each record for that question

mlmcc
0
 
LVL 8

Author Comment

by:newbie27
ID: 24341828
hi mlmcc

thanks for your input,

do you mean that i should have 20 group header and details section for all the questions to appear on the document?

please can you see the attached for the layout...

thanks
s

screenshot.JPG
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

 
LVL 100

Expert Comment

by:mlmcc
ID: 24341884
It depends on your data how you can build the report.

Crystal works on 1 record at a time.  So the information in the detail section is repeated for each record.
If you add a group then you get 1 group header/footer for each group.

If you have data like

Q1  Q  What is 7 + 3
Q1  A   a.  11
Q1  A   b.  12
Q1  A   c.  10
Q1  A   d.  9
Q2  Q  etc

mlmcc
0
 
LVL 8

Author Comment

by:newbie27
ID: 24349801
Hi mlmcc

I am unable to design the group header/footer on the crystal file, please can you help if i forward you the .rpt file for adding them to it?

I have also looked for some sort of tutorials to achieve this but didnt  manage to find one.

Please can you advise me on this?

Thanks
S
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 24349890
You can upload the file here.

Make a copy and change the extension to TXT

mlmcc
0
 
LVL 8

Author Comment

by:newbie27
ID: 24353184
Hi mlmcc,

Please have the crystal report design attached and also please see the example of how it should look in the other word document.

I have tried to make the crystal report follow the design as in the word document but just not coming right...

and finally the PDF file which I have tried to generate from the code ...

for some reason first and and third page on the PDF file is coming up as blank.... which it should not.

please can you rename the following names

GiftCodes-MasterTheArtOf.rpt.txt  ==> GiftCodes-MasterTheArtOf.rpt
 
GIFT-CODES-MasterTheArtOf-2009-0.txt ==>GIFT-CODES-MasterTheArtOf-2009-0.PDF

thank you so much for your help and time.

regards
s

GiftCodes-MasterTheArtOf.rpt.txt
example-of-how-MAO-test-will-loo.doc
GIFT-CODES-MasterTheArtOf-2009-0.txt
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 24354202
Detail A is too long to fit on a single page.  Shorten it so it will fit.  Remember it can only be 11" - margins - reportheader size - pageheadersize

You have NEW PAGE AFTER set for details A.  Since it fills the page you get a blank page.

I have attached an revision that should work

Is the test data as I showed?  If not how will it be in the database?
I think with your design you will need to use a subreport.

Are you planning to run multiple names in a report?
I think this would be better with a redesign using groups.

I'll come up with an idea

mlmcc
0
 
LVL 8

Author Comment

by:newbie27
ID: 24357307
hi mlmcc

i cant find any attachment, please can you resend it?

thanks
s
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 24357676
Sure I apparently forgot it

mlmcc
GiftCodes-MasterTheArtOfREv1.txt
0
 
LVL 8

Author Comment

by:newbie27
ID: 24362793
Thanks mlmcc

Atleast I am now not getting blank pages, please can you also advise if the width is good for printing on A4 sheets?

I would be really very grateful if you could also assist me in getting the data right to the report.

I mean the question and options

Thanks
S
0
 
LVL 8

Author Comment

by:newbie27
ID: 24366362
mlmcc,

I am having another problem with the CR being exported into PDF.

The above ExportAsPDF function failing when I change font giftcodeid to WASP 39HC

It seems like adobe is not liking it.

Please can you advise if this is also something you are aware of?

thanks
sam
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 24367462
I am not aware of it.  I would check the Adobe forum here or the Adobe knowledge base.

mlmcc
0
 
LVL 8

Author Comment

by:newbie27
ID: 24373069
Hi mlmcc

I have just looked into a bit more detail on this font, when i right clicked on the font name for its properteis and checked the embedding tab, it says restricted license embedding. no emdedding allowed.

please can you think of any tool or any way to change these settings on the font?

thanks
s
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 24375211
Even if I could, I couldn't say it here since that would be a violation of the font license.

You need to contact the owner/developer of the font or use a different font.

mlmcc
0
 
LVL 8

Author Comment

by:newbie27
ID: 24383138
ok thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

839 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