Link to home
Start Free TrialLog in
Avatar of newbie27
newbie27Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Crystal Report 11 Design advise

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
Avatar of newbie27
newbie27
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

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

Avatar of Mike McCracken
Mike McCracken

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
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
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
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
You can upload the file here.

Make a copy and change the extension to TXT

mlmcc
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
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
hi mlmcc

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

thanks
s
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

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
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
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
I am not aware of it.  I would check the Adobe forum here or the Adobe knowledge base.

mlmcc
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
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
ok thanks