Skip to main content

Search

Search

Serialization Reset For Each Record Using Db

Comments

4 comments

  • Avatar
    Canguita

    Hello Michael,

     

    Thank you very much for your post.

     

    In order to make sure, that are you requesting is to set your quantity field record as 1 after to print your labels?

     

    If yes, firstly you will need to fix your serial numbers getting the quantity from Database field. for it click on "File" menu > "Print" item > click the button for "Serial Number" > select the option "Get quantity from Database field" > select the proper field. 

     

    After this you will need to create a VBscript in your label to set the printed labels quantity to 1. In OnNewRercord() Event you will need to insert a code as this:

     

     

    'Define the object names.
    dim objConn
    dim strConn
    dim rs
     
    'Define the database connection parameter constants.
    Const adOpenStatic = 3
    Const adLockOptimistic = 3
    Const adCmdText = &H0001
     
    'Connect to the Excel file.
    Set objConn = CreateObject("ADODB.Connection")
    objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Seagull\Fruits.xls';Extended Properties=""Excel 8.0;HDR=YES;"""
     
    'Create a record set of one record which is the current record being printed.
    Set rs = CreateObject("ADODB.Recordset")
    rs.open "SELECT * FROM [Sheet1$]", objConn, adOpenStatic, adLockOptimistic, adCmdText
    rs.Find "Product = '" & Field("Sheet1$.Product") & "'"
     
    'Set the "Printed" field of the record to be "1".
    rs.Fields("Printed") = "1"
    rs.Update
     
    Where you will need to change the red text for your Excel version, correct path and Database fields.
     
    Please note that you will need to create this code in OnNewRecord() event instead of OnPrintEnd() as the last event only can update the current record.
     
    Please let me know if you have any further question.
    0
  • Avatar
    Legacy Poster

    Dear Carlos,

     

    Thank you so much for your detailed reply.

     

    I'll test and if there's anything wrong, I'll post a reply.

     

    Good day.

    0
  • Avatar
    Legacy Poster

    I am looking for the same thing how can I do it my database is a csv file mixed quote and comma how can I do it?

    Please help

       Thanks

    0
  • Avatar
    Domingo Rodriguez
    Moderator

    If you're looking to reset the serial number on your label each time a new record is printed, it doesn't matter to what type of database you're connecting to. Please check the following topic which will help you:

    http://seagullscientific.invisionzone.com/index.php?/topic/1800-to-restart-serialization-if-a-db-feild-change/

     

    This example is even more complex than what you're trying to achieve. In your case you would just need to set value = 0 "OnNewRecord" and to use "value = value + 1" on the "OnSerialize" event.

    0

Please sign in to leave a comment.