To Restart Serialization If A Db Feild Change フォローする

0
Avatar
Legacy Poster

I am looking to get a count on the labels I am printing and to get reset if the ship to address changes This is my how db looks like

Item     Qty        Ship To Address

abcd    2            KH497

adfd     5            KH497

tyrty     6            KH497

abcd    2            sd456

adfd     5            sd456

tyrty     6             sd456

The label quantity is set by data source from qty my database is a csv file mixed quote and comma I know that I need a vb script for this but I don't know vb can some one help me out

Thanks

6 コメント

0
Avatar
Legacy Poster
コメントアクション Permalink

If possible, add an extra column to your database called "Start Num" and just set them all to 1. Then link the counter field to this and it should restart to 1 for each new record.

0
Avatar
Domingo Rodriguez
モデレータ
コメントアクション Permalink

Find attached an example on how this can be done. Copy the .txt file to "c:\Seagull" please.

 

I've used an event based VBScript, where "OnNewRecord" event the following code is being used:

 

myold = mynew
mynew = Field("data.Ship To Address")
 
if Strcomp (myold, mynew) <> 0 Then
    value = 0
End If
 
This way, you compare the old and the new "address", and if they turn out to be different then you reset the counter.
0
Avatar
Legacy Poster
コメントアクション Permalink

Thank you

works very good

One more thing I am looking for is to have a total of labels printed (per ship to address) on all labels

Example:  KH497 13

0
Avatar
Domingo Rodriguez
モデレータ
コメントアクション Permalink

Unfortunately, it won't be possible to know beforehand how many labels you will print before the "Ship To" address changes, unless you open a second connection to the database by using VBScripting. 

Would it perhaps be sufficient if you print the total number of labels at the end of each "Ship To" address?

0
Avatar
Legacy Poster
コメントアクション Permalink

No what I am looking to get x of y cases send so how can I get a  the y if the y is coming from the database and in my case the identical copies of label is set by data source from Qty

Thank you

0
Avatar
Domingo Rodriguez
モデレータ
コメントアクション Permalink

Unfortunately, this is not possible as it would require BarTender to read data from more than one records while it is still processing the first record of the database. As mentioned, you would need to create a connection to your text database by using VBScript, and then read and sum the different quantities until the "Ship to Address Changes". The following VBScript code shows how you can open a text file in read mode by using VBScript. If the file doesn't exist, it will create it. Please note that this is just a very simple example which you will need to modify so that it is also capable of reading the Qty field:

 

On error resume next
Dim fs, file, fso, makedatafile, f
 
If IsNumeric(Value) = False Then 
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.FileExists("c:\testfile.txt")
    if f = False then 
        Set makedatafile = fs.CreateTextFile("c:\testfile.txt", False)
          Set file = fs.OpenTextFile("c:\testfile.txt")  
        makedatafile.writeline "1"
    Else
          Set file = fs.OpenTextFile("c:\testfile.txt")  
         Value = file.ReadLine
    End If
    Value = file.ReadLine
End if
Value = Value

ログインしてコメントを残してください。