Record Selection in Crystal Reports 9 using VB.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • freedom
    New Member
    • Apr 2007
    • 16

    Record Selection in Crystal Reports 9 using VB.net

    How to use the record selection formula in CR9 programatically using vb.net? I have a combo box that displays the date. If I select date, I can generate a report based on the selected date. Thanks in advance
    Last edited by Killer42; Nov 26 '07, 08:55 AM.
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    Pass this RecordSelection Formula to the Report:

    [code=vb]
    m_Report.Record SelectionFormul a ="{MyTable.MyDa teField} =Date(" & Format(Combo1.T ext,"yyyy,mm,dd ") & ")"
    [/code]

    Regards
    Veena

    Comment

    • freedom
      New Member
      • Apr 2007
      • 16

      #3
      Ah, I see, that's what Im missing, I acutally used that ".recordselecti onformula = Date & " combbox.text... .and it says a date-time is required here... I guess this is what Im missing. Thanks for your response. I check it out.

      Comment

      • freedom
        New Member
        • Apr 2007
        • 16

        #4
        Hi Veena,
        I tried to used this in my record selection, however, I received an error, "The ) is missing" when I checked it, any part here that I missed? thnks.

        VB code:
        CrystalReportVi ewer1.Selection Formula = "{vTITO_Rpt.Wor kDate} In Date (" & Format(cmbxDate From.Text, "YYYY,MM,DD ") & ") To Date (" & Format(cmbxDate To.Text, "YYYY,MM,DD ") & ")"

        Regards

        Comment

        • QVeen72
          Recognized Expert Top Contributor
          • Oct 2006
          • 1445

          #5
          Hi,

          For CR9, it .RecordSelectio nFormula.
          Looks like, you have not declared the Report Object..
          What code are you using to display the report...?
          Check this :

          m_Report.Select ionFormula = "{vTITO_Rpt.Wor kDate} In Date (" & Format(cmbxDate From.Text, "YYYY,MM,DD ") & ") To Date (" & Format(cmbxDate To.Text, "YYYY,MM,DD ") & ")"


          Regards
          Veena

          Comment

          • freedom
            New Member
            • Apr 2007
            • 16

            #6
            The "m_report" here you use is the Crystal Report viewer, right? I'm using CR9, tried to use the .RecordSelectio nFormula, but it's not working. I tried to use the previous post you have here but still to no avail. What do I miss here? Thanks
            Last edited by Killer42; Nov 26 '07, 08:57 AM.

            Comment

            • QVeen72
              Recognized Expert Top Contributor
              • Oct 2006
              • 1445

              #7
              Hi,

              Post your complete code here..
              It will be easy for me to Identify..

              Regards
              Veena

              Comment

              • freedom
                New Member
                • Apr 2007
                • 16

                #8
                Hi Veena,

                Here is my code I used, I can't find what's seems to the error here, but everytime I used it, I encountered the error "The ) missing" . Thanks in advance

                CrystalReportVi ewer1.ReportSou rce = New ReportName CrystalReportVi ewer1.ReportSou rce = ReportDocument
                CrystalReportVi ewer1.Selection Formula = "{vTITO_Rpt.Wor kDate} In Date (" & Format(cmbxDate From.Text, "YYYY,MM,DD ") & ") To Date (" & Format(cmbxDate To.Text, "YYYY,MM,DD ") & ")"
                CrystalReportVi ewer1.Show()

                Regards

                Comment

                • QVeen72
                  Recognized Expert Top Contributor
                  • Oct 2006
                  • 1445

                  #9
                  Hi,

                  Syntax of SelectionFormul a seems OK,
                  Did you check both the combo-boxes, have data..?
                  You may get error, if either one of them is Blank...

                  and FromDate < ToDate..?

                  Regards
                  Veena

                  Comment

                  • freedom
                    New Member
                    • Apr 2007
                    • 16

                    #10
                    Hi,

                    Yes, both combo boxes has data, I even tried to change the combo box to text box, inputting the date manuallu, but to no avail. Can we say that the code is ok?

                    Thanks

                    Comment

                    • QVeen72
                      Recognized Expert Top Contributor
                      • Oct 2006
                      • 1445

                      #11
                      Hi,

                      Selection formula syntax is OK.
                      But, Without Selection Formula, does your Code Work perfectly...?

                      Regards
                      Veena

                      Comment

                      • freedom
                        New Member
                        • Apr 2007
                        • 16

                        #12
                        HI Veena,

                        I tried to see check it on the crystal report "show formula" then I tried to used this in my code using the below syntax, it worked well. However, as you can see it was not based on the input on the combo box. It was manually inputted on the selection expert. Thanks

                        mySelectFormula = "{vTITO_Rpt.Emp No} In Date (2007, 10, 08) to DateTime (2007, 10, 09)"

                        Comment

                        • QVeen72
                          Recognized Expert Top Contributor
                          • Oct 2006
                          • 1445

                          #13
                          Hi,

                          I'am not sure, if this is correct..
                          In your selection formula you are saying "vTITO_Rpt.EmpN o"
                          Is EmpNo the Date field in table vTITO...?


                          Regards
                          Veena

                          Comment

                          • freedom
                            New Member
                            • Apr 2007
                            • 16

                            #14
                            Hi Veena,

                            Im sorry I posted a wrong one. Here is the code. Does it has something to do with the setting up of date format?Thanks.

                            mySelectFormula = "{vTITO_Rpt.Wor kDate} In Date (2007, 10, 08) to DateTime (2007, 10, 09)"

                            Comment

                            • QVeen72
                              Recognized Expert Top Contributor
                              • Oct 2006
                              • 1445

                              #15
                              Hi,

                              OK, How are the Values in ComboBox populated.
                              Post some sample data from Combobox.
                              also check the regional setting for Dates..


                              Regards
                              Veena

                              Comment

                              Working...