Results 1 to 12 of 12

Thread: Dynamic Crystal Reports 9 with VB6

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    45

    Question Dynamic Crystal Reports 9 with VB6

    I am loading a crystal report via VB6 and the report is going to show mobile phone numbers and ICCID numbers, Using the following code I can get the report to show the first 1000 mobile numbers. But if I want to get the report to show a different range of numbers it just brings back the same set of 1000 numbers

    VB Code:
    1. Private Sub Form_Load()
    2.  
    3. Dim Appl As New CRAXDRT.Application
    4. Dim Report As New CRAXDRT.Report
    5. Dim Rs As ADODB.Recordset
    6. Dim Conn As Connection
    7. Dim strSQL As String
    8.  
    9. Set Conn = New Connection
    10.  
    11. With Conn
    12.     'Set up an ODBC connection to Cerillion to the database defined in SystemDSN
    13.     .ConnectionString = "Provider=OraOLEDB.Oracle;User Id=Super;Password=Password;Data Source=" & ServerName & ";"
    14.     'Open the ODBC connection
    15.     .Open
    16.  
    17. End With
    18.  
    19. If frmJTPrint.optAll = True Then
    20.  
    21.     strSQL = "select Access_NO,ICCID from Test_Dec_Puk_Details tdPD, Test_Dec_GSM_PP_Access_Numbers tdGPAN where tdPD.ICCID = Ltrim(tdGPAN.Assoc_Access_No) and ICCID_Full = '" & FileIDToPrint & "'"
    22.  
    23. ElseIf frmJTPrint.optPhoneNumberRange = True Then
    24.  
    25.     strSQL = "select Access_NO,ICCID from Test_Dec_Puk_Details tdPD, Test_Dec_GSM_PP_Access_Numbers tdGPAN where tdPD.ICCID = Ltrim(tdGPAN.Assoc_Access_No) and ICCID_Full = '" & FileIDToPrint & "' and Access_NO >= '" & tempFrom & "' and Access_NO <= '" & tempTo & "'"
    26.  
    27. End If
    28.  
    29. Set Rs = New ADODB.Recordset
    30. Set Rs = Conn.Execute(strSQL)
    31. Set Appl = New CRAXDRT.Application
    32. Set Report = Appl.OpenReport(App.Path & "\Labels.rpt", 1)
    33. Report.Database.SetDataSource Rs, 3, 1
    34.  
    35. CRView.Refresh
    36.  
    37. CRView.ReportSource = Report
    38. CRView.ViewReport
    39. End Sub
    I am using two sql statements (one for "All" mobile numbers to be shown with a specific ID and one for a range of numbers, from A to B)
    These dont seem to be working, any help would be appreciated

    Thanks

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Dynamic Crystal Reports 9 with VB6

    You are calling this from Form_Load. This would mean that in order to run it again you would have to close the form and open it again. Since it runs the moment the form is loaded, how do you get to pick which option you want in the first place?

    If one is set as default, then that would be the one that run everytime the form loaded.

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    45

    Re: Dynamic Crystal Reports 9 with VB6

    There is a form before this form where the user selected to view all mobile numbers or just a selection (which they enter there and then). Then a "Preview" button is selected and the program runs this form

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Dynamic Crystal Reports 9 with VB6

    If you select the number range first, does it display properly?

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    45

    Re: Dynamic Crystal Reports 9 with VB6

    no it just displays the first lot of numbers it calls from the DB, I have tried taking and loading both SQL statements into and SQL editor and they both bring back the correct information...

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Dynamic Crystal Reports 9 with VB6

    Try this experiment and tell me what happens
    VB Code:
    1. 'comment out the lines in your program that I have commented out here
    2. 'If frmJTPrint.optAll = True Then
    3.  
    4.    ' strSQL = "select Access_NO,ICCID from Test_Dec_Puk_Details tdPD, Test_Dec_GSM_PP_Access_Numbers tdGPAN where tdPD.ICCID = Ltrim(tdGPAN.Assoc_Access_No) and ICCID_Full = '" & FileIDToPrint & "'"
    5.  
    6. 'ElseIf frmJTPrint.optPhoneNumberRange = True Then
    7.  
    8.     strSQL = "select Access_NO,ICCID from Test_Dec_Puk_Details tdPD, Test_Dec_GSM_PP_Access_Numbers tdGPAN where tdPD.ICCID = Ltrim(tdGPAN.Assoc_Access_No) and ICCID_Full = '" & FileIDToPrint & "' and Access_NO >= '" & tempFrom & "' and Access_NO <= '" & tempTo & "'"
    9.  
    10. 'End If
    In other words, the only SQL statement that can possibly run is the one for the number range, so lets see what happens.

  7. #7

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    45

    Re: Dynamic Crystal Reports 9 with VB6

    It just brings back ALL the numbers from the DB and it ends up be like 143 pages long, lol...The user should have to enter two mobile numbers (from - to) for this too work...

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Dynamic Crystal Reports 9 with VB6

    The query for optPhoneNumberRange brings back ALL numbers?

    On the form with the option button, do you have two textboxes in which the user can enter a number range if that is what they want?

  9. #9

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    45

    Re: Dynamic Crystal Reports 9 with VB6

    yes that is correct and in here they enter the range of numbers they want to see then select a "Display" button which displays the numbers they want to print via a listbox...This display via a listbox works fine for viewing both all the numbers or a select range...

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Dynamic Crystal Reports 9 with VB6

    Put a break on the Form Load and step through you code to see what the program is doing.

    You say the queries work fine when you run them in SQL/Plus right?

    Also, do a Debug.Print strSQL right after your End If. I want to see exactly what is getting passed back to your database.

  11. #11

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    45

    Re: Dynamic Crystal Reports 9 with VB6

    This is what is being parsed to the DB at the end of the IF STATEMENT:

    VB Code:
    1. select Access_NO,ICCID from Test_Dec_Puk_Details tdPD, Test_Dec_GSM_PP_Access_Numbers tdGPAN where tdPD.ICCID = Ltrim(tdGPAN.Assoc_Access_No) and ICCID_Full = '3'

  12. #12

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    45

    Re: Dynamic Crystal Reports 9 with VB6

    This is just a quick bump for this post... Still having the same problem with all data being returned? I have a feeling the Where Clause isnt being parsed to my CR9? It seems to bring back the data upto the point of the Where Clause...Not sure if this is the answer to the problem but any help would be much appreciated?

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