To Restart Serialization If A Db Feild Change
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
-
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 -
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 = mynewmynew = Field("data.Ship To Address")if Strcomp (myold, mynew) <> 0 Thenvalue = 0End IfThis way, you compare the old and the new "address", and if they turn out to be different then you reset the counter.0 -
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 -
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 -
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 -
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 nextDim fs, file, fso, makedatafile, fIf IsNumeric(Value) = False ThenSet fs = CreateObject("Scripting.FileSystemObject")Set f = fs.FileExists("c:\testfile.txt")if f = False thenSet makedatafile = fs.CreateTextFile("c:\testfile.txt", False)Set file = fs.OpenTextFile("c:\testfile.txt")makedatafile.writeline "1"ElseSet file = fs.OpenTextFile("c:\testfile.txt")Value = file.ReadLineEnd IfValue = file.ReadLineEnd ifValue = Value0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
6 Kommentare