Zum Hauptinhalt gehen

Suche

Suche

Save The Field Data Bartender To An Excel

Kommentare

1 Kommentar

  • Avatar
    Ian Cummings
    Moderator

    Yes, an event based VB script can be used to read in a value at the start of a print job, and then write an updated value back to the same field/record at the end of the print job.  Like when reading an updated serial number for a product for example.

     

    Another example is to use a VB script to mark a record that is used in a print job as having been printed.  Here is a code example to give you an idea:

     

    OnNewRecord event
     
    '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 "YES" thus flagging it as having been printed.
    rs.Fields("Printed") = "YES"
    rs.Update
    
    
    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.