Solved

Crystal Report 11 Design advise

Posted on 2009-05-08
16
213 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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
Comment Utility
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
Comment Utility
You can upload the file here.

Make a copy and change the extension to TXT

mlmcc
0
 
LVL 8

Author Comment

by:newbie27
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 8

Author Comment

by:newbie27
Comment Utility
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
Comment Utility
Sure I apparently forgot it

mlmcc
GiftCodes-MasterTheArtOfREv1.txt
0
 
LVL 8

Author Comment

by:newbie27
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
ok thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

12 Experts available now in Live!

Get 1:1 Help Now