Results 1 to 20 of 20

Thread: crystal parameters

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Posts
    74

    crystal parameters

    i have a crystal report that has 4 parameters on it (par 1 = customer, par 2 = division, par 3 = salesman, par 4 = company). if i fill the parameters with valid data i get the proper result set. my issue is if i leave a parameter blank i get no result set. is there a way i can run the report and skip 1 or more parameters. or can i set a parameter as optional on the report? i do not want to use a selection formula. the table i am using has close to 400 000 records and i know that a selection formula will load everything and then filter down. this process takes way to long. can someone please help.

    Thank You,
    THomas

  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 parameters

    You could use an ADO recordset with a query that takes 0 - 4 parameters.
    Then set the rs as the .DataSource for the report. Allot faster and your only
    using what you actually need.

    In CR setup the report so it has all the controls on it that you need, bound to
    the correct fields. Then when you create your rs if parameters are passed or
    not, CR report will be isolated.

    HTH
    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

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Posts
    74

    Re: crystal parameters

    how do you do that? do you mean linking my report to a recordset instead of a data source (odbc).can you send me an example or a place to look.

    Thank you

  4. #4
    Lively Member
    Join Date
    Dec 2004
    Posts
    121

    Re: crystal parameters

    There is a good walkthrough titled "Reporting Off ADO Datasets" in VB.Net help. Type "crystal dataset" to search VB.Net help and it will come up in the results.

    Basically, you have to create your dataset, then connect to the dataset object then set up the report pointing to the dataset instead of your database. This is just the structure of the dataset. It does not include data. You have to fill the dataset with data using the data adapter.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Posts
    74

    Re: crystal parameters

    Thanks but I'm using VB6...

    I finally got it working by linking the report to a TTX file... RobDog, is this what you were suggesting? Now i need to figure out how to deal with sub reports, do i have to link the sub report to it's own TTX file?

    Also, is this best practice when working with VB and MSSQL SERVER taking into consideration that i needs flexible parameters that sometimes get used and other times don't?

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

    Re: crystal parameters

    A ttx file is also an option, but I havent used them before.

    Here are a few links to some of my VB6 examples for you.
    http://www.vbforums.com/showthread.php?t=316865
    http://www.vbforums.com/showthread.php?t=316267
    http://www.vbforums.com/showthread.php?t=303105

    And this one is for .NET
    http://www.vbforums.com/showthread.php?t=322513

    HTH
    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

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Posts
    74

    Re: crystal parameters

    thanks for the quick reply, you said you never used a ttx file. i though the only way to pass a rs to a rpt is if you rpt is created using a ttx file instead of a odbc datasource. i am using crystal 8.5 what version are you using? itred to run a report with the code from one of the links you gave me and i get the following message "server not yet open". what is this? and how do i get this report to preview to screen instead of going straight to the printer?

    code start:----------------

    Private Sub Command1_Click()
    Dim cnn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim str1 As String
    Dim moReport As CRAXDRT.Report

    Set CrxApp = New CRAXDRT.Application
    Set moReport = New CRAXDRT.Report

    sServer = "gs3zt01"
    sDatabase = "milehighdvd"
    sUserName = "sa"
    sUserPwd = "eicon_dev"

    Set moReport = CrxApp.OpenReport("c:\program files\eicon\reports\Salesman_Commission_Summary new.rpt", 1)

    moReport.Application.LogOnServer "P2SSQL.DLL", sServer, sDatabase, sUserName, sUserPwd
    moReport.Database.Tables(1).SetLogOnInfo sServer, sDatabase, sUserName, sUserPwd

    Call modDatabase.SetDatabases(cnn, 1)

    str1 = "select * from Report_Qry_Salesman_Commission_Summary"
    rs.CursorLocation = adUseServer
    rs.Open str1, cnn, adOpenForwardOnly, adLockOptimistic, adCmdText

    moReport.Database.SetDataSource rs, 3, 1
    moReport.DisplayProgressDialog = True
    moReport.PrintOut True, 1

    Call modDatabase.CloseDatabases(cnn)

    End Sub
    code stop:----------------

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

    Re: crystal parameters

    What are you using for your database?
    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

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Posts
    74

    Re: crystal parameters

    i'm using vb6, sql server 2000, and crystal reports 8.5

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

    Re: crystal parameters

    Ok, I have all of those and the same versions. So, does your report contin a subreport?
    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

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Posts
    74

    Re: crystal parameters

    this report doesn't but i will have some reports that will have one or more subreports. is that an issue?

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

    Re: crystal parameters

    No, not really. It just means that you may have to log in to other tables.
    If I get some tim eI will put together a small demo for you.
    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

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Posts
    74

    Re: crystal parameters

    thanks that would be perfect, you da man robdog888

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

    Re: crystal parameters

    Did you want to use the CR Report Viewer Control for a print preview option?
    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

  15. #15

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Posts
    74

    Re: crystal parameters

    the crviewer would be just fine.

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

    Re: crystal parameters

    If your report has ADO as a datasource then this should work with it.
    I didnt have enough time to completely test it against my servers but I figure
    there may be issues anyways. So give it a try. This assumes that you do not
    have a subreport.

    VB Code:
    1. Option Explicit
    2. 'Add references to:
    3. 'Crystal Reports Viewer Control
    4. 'Crystal Reports 8.5 ActiveX Designer Run Time Library
    5. 'Crystal Reports 8.5 Library
    6. 'Microsoft ActiveX Data Objects 2.x Library
    7. Private moApp As CRAXDRT.Application
    8. Private moReport As CRAXDRT.Report
    9. Private moCnn As ADODB.Connection
    10. Private moRs As ADODB.Recordset
    11.  
    12. Private Sub Command1_Click()
    13.     Set moRs = New ADODB.Recordset
    14.     moRs.Open sSQL, moCnn, adOpenKeyset, adLockOptimistic, adCmdText
    15.     If moRs.BOF = True And moRs.EOF = True Then
    16.         MsgBox "No Record(s) returned!", vbOKOnly + vbExclamation
    17.     Else
    18.         Dim sUserName As String
    19.         Dim sUserName As String
    20.         Dim sUserPwd As String
    21.         Dim sServer As String
    22.         Dim sDatabase As String
    23.         Dim sPara1 As String
    24.         Dim sPara2 As String
    25.         Set moReport = New CRAXDRT.Report
    26.         Set moReport = moApp.OpenReport(App.Path & "\MyReport.rpt", 1)
    27.         sUserName = "MyUserName"
    28.         sUserPwd = "mypassword"
    29.         sServer = "ServerName"
    30.         sDatabase = "DatabaseName"
    31.         sDriver = "P2SSQL.DLL"
    32.         moApp.LogOnServer "P2SSQL.DLL", sServer, sDatabase, sUserName, sUserPwd
    33.         moReport.Database.Tables(1).SetLogOnInfo sServer, sDatabase, sUserName, sUserPwd
    34.         moReport.ParameterFields.Item(1).ClearCurrentValueAndRange
    35.         moReport.ParameterFields.Item(1).AddCurrentValue sPara1
    36.         moReport.ParameterFields.Item(2).ClearCurrentValueAndRange
    37.         moReport.ParameterFields.Item(2).AddCurrentValue sPara2
    38.         moReport.Database.SetDataSource moRs, 3, 1
    39.         CRViewer1.ReportSource = moReport
    40.         CRViewer1.ViewReport
    41.         CRViewer1.ShowFirstPage
    42.     End If
    43. End Sub
    44.  
    45. Private Sub Form_Load()
    46.     Dim sSQL As String
    47.     Dim sDB As String
    48.     Dim sServer As String
    49.     sSQL = "SELECT * FROM Table1 WHERE Something = SomethingElse;"
    50.     sDB = "MyDatabase"
    51.     sServer = "MyServer"
    52.     Set moCnn = New ADODB.Connection
    53.     moCnn.ConnectionString = "provider=sqloledb;data source=" & sServer & ";initial catalog=" & sDB & ";integrated security=sspi;"
    54.     moCnn.Open
    55. End Sub
    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

  17. #17

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Posts
    74

    Re: crystal parameters

    the code worked and it was extremely quick. the only thing is i will need to have reports that have one or more subreports. how do i go about that? what mods to the existing code do i need to make in order for this to work.

    once again thanks a lot.

    Thomas

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

    Re: crystal parameters

    I was hoping that that would bnot come up because I have not had too much success with them. Let me see
    if I can get a good example going for you. Be back later.
    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

  19. #19

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Posts
    74

    Re: crystal parameters

    i got the ado report setup and working fine. my report is linked to a table that has 200,000 records. if i run the report i get the following results:

    1-report linked to an odbc connection takes about 6 sec
    2-report linked to ttx file takes about 1.5 min
    1-report linked to an ado rs gets about half way and errors out every single time and half way means 8 min.

    i ran these reports from my vb app and directly from crystal and i always get the same results.

    any ideas?

    also do you know if ttx reports are supported in crystal 9?

    Thomas

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

    Re: crystal parameters

    Probably, but I only have 8.5 Developer. What is the error when using ADO? Are all these the
    subreports and their connection types or individule report testing by you?
    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

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