Results 1 to 32 of 32

Thread: [CR XI] - How to avoid printing twice ???

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Question [CR XI] - How to avoid printing twice ???

    I have to print orders for a particular selected date ( say 25th Aug 07), now if i take the prints today(20th Aug 07) and there are more orders placed tomorrow for (25th Aug), how do i take the prints of newly booked orders only and not the old ones ??? i.e. i need to avoid taking print twice !

    How can i do this ???

  2. #2
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: [CR XI] - How to avoid printing twice ???

    I would set up a flag in your database on whether or not the order has been printed. When you call your routine to print them just mark that field printed.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Re: [CR XI] - How to avoid printing twice ???

    How can i set up flag in the database... I am using Oracle 9i database. Is there any facility in the CR XI for the same purpose ?

  4. #4
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: [CR XI] - How to avoid printing twice ???

    Quote Originally Posted by LuxCoder
    How can i set up flag in the database... I am using Oracle 9i database. Is there any facility in the CR XI for the same purpose ?

    It would just be an added field (ie. Order_Printed) to your order table. When the order is created populated the new field with something like an "N". When you call your routine to print the order, change it to a "Y". Only have your crystal report print orders that Order_Printed = "N". Not sure how you are calling your print routines but it is probably the most practical way to go about it.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Re: [CR XI] - How to avoid printing twice ???

    okay... anymore ideas apart from this ???

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Re: [CR XI] - How to avoid printing twice ???

    anyone ???

  7. #7
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,513

    Re: [CR XI] - How to avoid printing twice ???

    To be safe you should check if everything printed correctly before you mark the records as printed.

    Code:
    If MsgBox("Did Everything Print Correctly?", vbYesNo + vbQuestion, "Data Report") = vbYes Then
        ' go mark records
    endif

  8. #8
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: [CR XI] - How to avoid printing twice ???

    Logic would dictate that the most efficient way you are going to be able to tell if a record has already printed is to have a ALREADY_PRINTED flag in the database for that record.

    Of course, there are always other ways. You could have a separate table in the database listing <some key> of all the records that have been printed. Then, when you print you can check that table and see if the record has already printed.
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Re: [CR XI] - How to avoid printing twice ???

    i am viewing and sorting the required data in Crystal Reports so how can i mark these already printed data in the Database ? Through VB code or CR ? In both case how ???

  10. #10
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: [CR XI] - How to avoid printing twice ???

    I think you may have to do what wes4bt said. Use your vb code to call the report using a parameter of PRINT_FLAG not set. Once the report finishes, ask if everything is OK. If it is, use the same paramter in a SQL_UPDATE to update the database to reflect the new status.

    I think I read somewhere that CR can update the db, but I don't know how.

    You might try the CR forum also

    http://support.businessobjects.com/f...=5&ps=25&pn=1&
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  11. #11
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: [CR XI] - How to avoid printing twice ???

    Quote Originally Posted by LuxCoder
    i am viewing and sorting the required data in Crystal Reports so how can i mark these already printed data in the Database ? Through VB code or CR ? In both case how ???

    Do it in the same vb code that you are using to call your report. just add a function that will mark a flag in your database as being printed. when you pull the data for your report use the flag as criteria on which you should print the data or not.

  12. #12
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: [CR XI] - How to avoid printing twice ???

    This is probaly the best way to do this (a printed flag on the row). But be carefull, once you garther the data (based on a select) the data can change based on someone adding new data or updateing some line that requires another print. You want to be carefull not to mark those rows as printed.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Re: [CR XI] - How to avoid printing twice ???

    I have no idea on how to set up flag in the database... it's like my query is done in Crystal Reports now and not in the VB form... I think for the afore mentioned solution i will have to pass the query through VB form...

    I am querying upon the Delivery date of my recordset through CR. Can anyone tell me how do i pass this query from Vb form and mark the flag 'P'-Printed 'NP'-Not Printed to the field 'Print' in datatable 'Booking' ?

    Codes would be helpful.

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Re: [CR XI] - How to avoid printing twice ???

    Any one ???

  15. #15
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: [CR XI] - How to avoid printing twice ???

    You can't do it from CR. To mark the row as printed you must do it from VB. You could run a query that gets the PK's of all rows to be printed. Send that to CR as a recordselection criteria. Once the report has printed you use the same set of PK to update the Oracle table from VB and set the printed column to whatever you have decided to mark it as to show it has been printed.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Re: [CR XI] - How to avoid printing twice ???

    what's PK ? can u give a code example for it ?

  17. #17
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: [CR XI] - How to avoid printing twice ???

    PK is the primary key. Do you know SQL? Do you know how to pass a Selection Formula to CR?
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  18. #18

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Re: [CR XI] - How to avoid printing twice ???

    no i dont know ! Plz help ! :-(

  19. #19
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: [CR XI] - How to avoid printing twice ???

    Don't know what SQL? How to call CR report? What do you have so far? I can't write it all from scratch for you.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  20. #20

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Re: [CR XI] - How to avoid printing twice ???

    Well, this is what i have so far. I have filtered the required data according to field 'Delivery Date' in the CR. Now what i want is to pass the query from the VB and mark them printed in the database.

    vb Code:
    1. Option Strict On
    2. Imports CrystalDecisions.CrystalReports.Engine
    3. Imports CrystalDecisions.Shared
    4.  
    5. Public Class WorkPrint
    6.  
    7.     Private Sub WorkPrint_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
    8.         Master.btnact = "Z"
    9.         Master.NewButton.Enabled = True
    10.         Master.EditButton.Enabled = True
    11.         Master.SaveButton.Enabled = False
    12.         Master.DeleteButton.Enabled = True
    13.         Master.UndoButton.Enabled = True
    14.         Master.RedoButton.Enabled = True
    15.         Master.FirstButton.Enabled = True
    16.         Master.BackButton.Enabled = True
    17.         Master.NextButton.Enabled = True
    18.         Master.LastButton.Enabled = True
    19.         Master.CloseButton.Enabled = True
    20.         Master.SearchButton.Enabled = True
    21.     End Sub
    22.  
    23.     Private Sub WorkPrint_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    24.         ConfigureCrystalReports()
    25.     End Sub
    26.  
    27.     Private Sub ConfigureCrystalReports()
    28.  
    29.  
    30.         Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
    31.         myConnectionInfo.ServerName = "orcl"
    32.         myConnectionInfo.DatabaseName = "sun"
    33.         myConnectionInfo.UserID = "scott"
    34.         myConnectionInfo.Password = "tiger"
    35.  
    36.         SetDBLogonForReport(myConnectionInfo)
    37.  
    38.     End Sub
    39.     Private Sub SetDBLogonForReport(ByVal myConnectionInfo As ConnectionInfo)
    40.  
    41.         Dim myTableLogOnInfos As TableLogOnInfos = CrystalReportViewer1.LogOnInfo()
    42.         For Each myTableLogOnInfo As TableLogOnInfo In myTableLogOnInfos
    43.             myTableLogOnInfo.ConnectionInfo = myConnectionInfo
    44.         Next
    45.  
    46.     End Sub
    47. End Class

  21. #21
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: [CR XI] - How to avoid printing twice ???

    As I said earlier you can not update the database from CR. You must write the update in VB and perfrom it though an Oracle Connection object.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  22. #22

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Re: [CR XI] - How to avoid printing twice ???

    can u help me with codes ?

  23. #23
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: [CR XI] - How to avoid printing twice ???

    What are the field? How do you connect to the Oracle database?
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  24. #24

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Re: [CR XI] - How to avoid printing twice ???

    This is an example of how i connect to db...

    vb Code:
    1. crs.Open("select * from pmeasurement where cuid ='" & ChildForm.Text2.Text & "'", Module1.db, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

    I have to filter upon delivery date 'dlvrdt' which is selectable from datetimepicker.

  25. #25
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: [CR XI] - How to avoid printing twice ???

    Are you using VB6 or .Net? I assume from the ADODB reference that this is VB6. What is cuid? What are the field names you really want? You shouldn't just be bring everyting back if you don't really need it.
    Last edited by GaryMazzone; Sep 21st, 2007 at 08:07 AM.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  26. #26

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Re: [CR XI] - How to avoid printing twice ???

    i am using .net for desktop application... cuid is the customer id... that was an example for connection but i want to filter the pmeasurement for delivery date.

  27. #27
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: [CR XI] - How to avoid printing twice ???

    If you are using .Net you should be using ADO.Net not the older ADODB database access functions. So if cuid is the customer id what is the primary key for the table? What is the delivery date field named? What is the CR name? How are you calling CR?

    Your code above never shows the call to display or print the CR.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  28. #28

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Re: [CR XI] - How to avoid printing twice ???

    I came to know about ADO.net recently when i have almost finished my project... now i cannot rectify all of them. Delivery date field is 'dlvrdt' and the CR name is Workorder.rpt. I have attached this report to the CR viewer in my form which opens the respective report on load event.

  29. #29
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: [CR XI] - How to avoid printing twice ???

    Quick and not tested
    vb Code:
    1. Dim strSQL As String
    2. strSQL = "Select PrimaryKeyField From  pmeasurement where Printed = 'N' Or Printed Is NULL"
    3. crs.Open strSQl,Module1.db, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic
    4.  
    5. If Not crs.BOF and Not crs.EOF Then
    6.   Dim strFiter As String
    7.   strFilter = {PrmaryKeyField} In ["
    8.   Do Unitl crs.EOF
    9.        strFitler = strfilter & crs.Fields(0).Value & ","
    10.        crs.MoveNext
    11.   Loop
    12.   strFitler = Left(strFilter,Len(strFilter -1)) & "]"
    13.   'your  cr reprort
    14.    crReport.RecordSelectionFormula = strFitler
    15.    'Show you report.
    16.    'After Report Done
    17.    strFilter = strFilter.Replace("[","(").Replace("]".")")
    18.    strsql = "Update pmeasurement Set Printed = 'Y' Where PrimaryKeyField  " & the strFitler var (taking out the part bewennd {}
    19.    the ADODB.Connection.Execute strSQL
    20. End If
    Last edited by GaryMazzone; Sep 21st, 2007 at 09:12 AM. Reason: Added code tags,Change CR In Function
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  30. #30

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Unhappy Re: [CR XI] - How to avoid printing twice ???

    Thanks for the codes.

    I want to show you complete scenario of what i am trying to achieve

    I have three measurement tables in Oracle DB which contains customer's measurement according to Customer ID (Cuid):

    1. Pmeasurement
    2. Smeasurement
    3. Cmeasurement &
    4. Jmeasurement

    I have a table named 'Order' in which i have booking details of customer out of which we require the following fields:

    1. Cuid (Customer ID)
    2. Orderno (Order Number)
    3. DelDate (Delivery Date)

    In crystal reports i have WorkOrder.rpt which consists of four subreports i.e. Pmeasurement, Smeasurement, Cmeasurement & Jmeasurement. Now, i have a parameter set to DelDate in 'Order' (Oracle DB) which further filters the measurements of that particular customer whose order is booked on 'DelDate'. As a result, WorkOrder.rpt gives me the measurements of all the customers whose delivery is due on a particular date.

    Now i want to mark the orders in 'Order' table in DB as 'Printed' (Y/N). In CR, the parameter is already set as DeliveryDate. How do i pass the query through VB form to select Orders whose Measurements have been printed and then mark them printed or not printed.

  31. #31

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Re: [CR XI] - How to avoid printing twice ???

    Mr.Gary... u there ?

  32. #32
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: [CR XI] - How to avoid printing twice ???

    You can not. REPEAT YOU CAN NOT update the database from CR. You must do this using the application and connect to the database and issue and update statement.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

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