In trying to refine my label code so I can print a variable number of copies before the printer cuts the label roll (the previous code used a loop, but each label was it's own print job, so the printer cut off the label off the roll after each label), I have tried the following code using NewDocument(). But it will only print 1 copy. I've tried substituting a hard integer instead of vQty variable, and still just one label prints. It seems that the Finishpage() is terminating the job and sending it to the printer, rendering the NewDocument(2) and FinishDocument() code unexecuted. Any suggestions?
#Include "sbasic_include.sbas"
var vRS2 as Int
var vItemNum as String
var vItemDesc as String
var vPONum as String
var vAnswer as String
var vFinal as Int
var vQty as Int
var vAnswer2 as String
If @Mode() < 3
{
vAnswer = @PromptForUserInput("Key in the Item Number you want to print labels for", "")
vItemNum = vAnswer
vRS2 = @XResultSetSearch(@FN, "Inventory", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!ItemNum=" + vItemNum)
If @XresultSetTotal(vRS2) = 1 // if there is exactly one matching record in Inventory, pull data from Inventory into printstring job
{
vItemDesc = @XResultSetValue(vRS2, "ItemDesc")
vPONum = @XResultSetValue(vRS2, "CurrentPONum")
vAnswer2 = @PromptForUserInput("How many labels would you like to print?", "")
vQty = vAnswer2
AlternateDefaultPrinter("wcLabel1")
NewDocument(vQty)
NewPage(840, 240)
PrintPageOrientation(2)
PrintString(vItemNum, 6, 6, 0, " ARIAL", 11, 0)
PrintString(vItemDesc, 6, @PageExtentY(), 200, " ARIAL", 8, 0)
PrintString("---------------", 160, 48, 0, " ARIAL", 9, 0)
PrintString("Company 918-xxx-xxxx", 15, 54, 0, " ARIAL", 9, 0)
PrintString("PO#" + " " + vPONum, 160, 54, 0, " ARIAL", 9, 0)
PrintString("
www.company.com", 15, 63, 0, " Arial", 8, 0)
FinishPage()
FinishDocument()
RestoreDefaultPrinter()
}
If @XresultSetTotal(vRS2) < 1
{
@Msgbox("This Item # does not exist. Reenter the number","","")
}
XResultSetClose(vRS2)
}