Changing copies for an Alternate Label when a database record is not found 追蹤

0
Avatar
Trey Holst

I have created a label that pulls data from a stored procedure in SQL Server.  Generally when a record is not found, it will leave the fields blank.  I'm sending back a specific error message in one of the fields that changes the template that is used.  

I have the alternate label working, however if they are printing 75 copies of the label and a database record is not found, they get 75 copies of the error message.  I'm trying to find a way to override the number of copies so only one label prints out.  I have tried using the following script in the OnPrintJobStart event, but it's not working:

IF Format.Objects("txtErrorMessage").Value = "No BoxQuantity Record Found" THEN _
Job.PrinterCopies = 1

3 意見

0
Avatar
Pete Thane
評論操作 永久連結

I think OnPrintJobStart BarTender will not have accessed the database yet to check the field so you probably need to run the VB OnNewRecord. However I dont quite follow your logic. If the users are getting 75 error messages, that is saying to me that print process is being run 75 times and so changing the number of copies will not effect this as instead you will get 1 label printed 75 times.

Where does the 75 copies value come from? 

0
Avatar
Trey Holst
評論操作 永久連結

The number of copies comes from a drop file.  My drop file does not have all the information I need so I send back the query prompt value from Integration Builder to the label so it can make the database call.  I have not figured out how to make a database call from inside of integration builder and process the returned data.  If you know how to do that, and can point me in the right direction, I think it would be way cleaner.

0
Avatar
Pete Thane
評論操作 永久連結

Just to get this right, the number of copies come from the trigger file normally but if 0 then you want to print the figure from the database?

If this is the case

  1. I would add a Named field on the label and link that to the trigger file copies value. You will need to configure this in Integration Builder too.
  2. Add another field onto the label and set this as a VB Script Event Controlled Script.> OnNewRecord and configure it as below.
  3. Configure the File > Print Copies value to link to the Data Source in 2

For the fields in 2 and 3 drag these off to the side of the label so they are not in the printable area and so will not print but are just there to be referenced more easily

VB:

OnAutoselectEvent

 Value = "1"

OnNewRecord

Value = "1"

Value1 = <double click on name of named data source from 1 above in right hand column>

Value2 = <double click on database filed name with copies>

If Value1 = "" then

Value = Value2 

Else Value = Value1

end if

Value = Value

登入寫評論。