Results 1 to 5 of 5

Thread: Crystal report selection formula

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2008
    Location
    selangor, Malaysia
    Posts
    71

    Crystal report selection formula

    I have a problem with the selection formula to be used by crystal report 10. At first I just set one selection formula and it's work and now i want to used two selection formula but I do not know how to write it. Below is the code and the word highlight with red color is the formula i want to add.Can anyone teach me how..


    Code:
    
    Private Sub ListView1_DblClick()
    
            
            ndLeaApprEmpNo = Trim(ListView1.SelectedItem.SubItems(3))
            ndLeaApprLCode = Trim(ListView1.SelectedItem.SubItems(1))
            ndLeaApprDt = Trim(ListView1.SelectedItem.SubItems(4))
            'MsgBox ndLeaApprEmpNo & ", " & ndLeaApprLCode & ", " & ndLeaApprDt
            Unload Me
            
            Me.MousePointer = vbHourglass
            Dim crApp As CRAXDRT.Application
            Dim Report As CRAXDRT.Report
            Dim strSelectionfrm As String
            Set crApp = New CRAXDRT.Application
            Set Report = crApp.OpenReport("C:\Program Files\Microsoft Visual Studio\VB98\Projects\LeaveApp\LeaveForm2.rpt")
        
        
            Report.Database.Tables(1).SetLogOnInfo "SQL", "tebrauteguh", "sa", "sa"
            '{tblLeaveApp.EmpNo}='" & ndLeaApprEmpNo & "' -->another selection formula i want to add, how to combine both
            strSelectionfrm = "{tblLeaveApp.Date_App}='" & ndLeaApprDt & "'"
    
            Report.RecordSelectionFormula = strSelectionfrm
            Report.DiscardSavedData
            Form8.CRV.ReportSource = Report
            Form8.CRV.ViewReport
            
            Form8.Show
            Form6.Hide
        Me.MousePointer = vbNormal
            
    
    End Sub

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Crystal report selection formula

    Thread Moved
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: Crystal report selection formula

    Code:
    strSelectionfrm = "{tblLeaveApp.Date_App}='" & ndLeaApprDt & "' AND {tblLeaveApp.EmpNo}='" & ndLeaApprEmpNo & "'"

  4. #4
    New Member
    Join Date
    Jun 2016
    Posts
    14

    Re: Crystal report selection formula

    Can anyone help me to sort by date using selection formula?
    Im currently using this codes
    Code:
       Me.CrystalReport11.SetDataSource(Me.DtrdbDataSet)
            Me.CrystalReportViewer1.SelectionFormula = "{DTR_REC.SDATE} IN DateValue (" & DateTimePicker1.Value.ToString("MM/dd/yyyy") & " ) TO DateValue (" & DateTimePicker2.Value.ToString("MM/dd/yyyy") & " )" And "{DTR_REC.MEM_CODES} =" & Me.txtpin.Text
            Me.CrystalReportViewer1.RefreshReport()
            Me.CrystalReportViewer1.Refresh()

    But the problem is 8/1/2016 found on the last portion.. It should be on the first data above...like in ascending order

    8/1/2016
    8/2/2016
    upto
    8/31/2016

    Name:  dtr.jpg
Views: 4296
Size:  51.4 KB

  5. #5
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: Crystal report selection formula

    You should order the data set or use the Record Sort Expert
    If you decide to use the RecordSort Expert, it's located in :
    main menu
    Report
    RecordSort Expert

    and select the field(s) that you want to use to order the report output
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width