Solved How to call a two function after printing a receipts (1 Viewer)

nector

Member
Local time
Today, 19:29
Joined
Jan 21, 2020
Messages
461
Dear all,

Is it possible someone can have an idea how to call two functions immediately after successful printing of a receipt, the print function is stated below, and so once its run and the document comes out, I need to call the other two functions which links to two APIs to update inventory. If no data to print, then the calling of two functions must be aborted with the message "not data to print", Stock will not be updated!

Code:
DoCmd.OpenReport "RptPosReceipts", acViewPreview, "", "", acNormal
DoCmd.RunCommand acCmdPrint


Call CmdSalesQuantitesPOS_Click
Call CmdSavePosMasterQTY_Click


The two functions should never be called if there is no data to print because at that point it means the system failed to generate the invoice detail meaning an error and so automatically it should abort.
 
Check your count of records returned by the source query for your report before trying to print it.
If it's zero don't try and print it, and don't call your other routines.
 
@
Check your count of records returned by the source query for your report before trying to print it.
If it's zero don't try and print it, and don't call your other routines.

How do I do the count, sorry for sounding foolish?????


Here is my query

Code:
SELECT tblPOSStocksSold.ItemSoldID, tblPOSStocksSold.PosDate, tblPOSStocksSold.SalesType, tblPOSStocksSold.CashReceived, tblPOSStocksSold.CashChange, tblPOSStocksSold.Cashier, tblPOSStocksSold.LocalPurchaseOrder, tblPOSStocksSold.OrignalInvoiceCode, tblPOSStocksSold.OrignalInvoiceNumber, tblPOSStocksSold.DocumentControls, tblPOSStocksSold.TheNotes, tblWarehouse.Warehouse, tblPOSStocksSold.DocID, tblProducts.ProductName, tblPosLineDetails.ProductID, tblPosLineDetails.QtySold, tblPosLineDetails.RRP, tblPosLineDetails.SellingPrice, tblPosLineDetails.Tax, tblPosLineDetails.TaxClassA, (((([SellingPrice])/(1+Nz([Tax],0)))+(IIf([SellingPrice]>[tblPosLineDetails].[RRP],(([SellingPrice]*Nz([Tax],0))/(1+Nz([Tax],0))),(([tblPosLineDetails].[RRP]*Nz([Tax],0))/(1+Nz([Tax],0))))))*[QtySold]) AS Totals, (IIf([SellingPrice]>[tblPosLineDetails].[RRP],(([SellingPrice]*Nz([Tax],0))/(1+Nz([Tax],0))),(([tblPosLineDetails].[RRP]*Nz([Tax],0))/(1+Nz([Tax],0))))) AS VATs, tblPOSStocksSold.BuyerTPIN, tblPOSStocksSold.FCRate, tblPOSStocksSold.CurrencyType, tblPOSStocksSold.CreditCards, tblPosLineDetails.Duty, tblPosLineDetails.ExciseClass, ((([QtySold]*[SellingPrice]))/(1+[Tax])) AS TaxableValue, (([TaxableValue]*(([Duty])/(1+[Duty])))) AS ExiceDuty, [TaxClassA] & [ExciseClass] AS TaxRates, ((IIf(([TaxClassA]="TV"),(([QtySold]*[SellingPrice])/(1+[TurnoverTax])),0))*[TurnoverTax]) AS TOTTax, tblPosLineDetails.TurnoverTax, tblPosLineDetails.Bettings, ((IIf(([TaxClassA]="BG"),(([QtySold]*[SellingPrice])/(1+[Bettings])),0))*[Bettings]) AS BETTax, tblPOSStocksSold.vsdcRcptPbctDate, tblPOSStocksSold.rcptNo, tblPOSStocksSold.intrlData, tblPOSStocksSold.rcptSign, tblPOSStocksSold.sdcId, tblPOSStocksSold.sdcId, tblPOSStocksSold.SqrCode, tblDocuments.DocCodes, tblDocuments.DocType, tblCustomers.Company, tblCustomers.TPIN, tblCustomers.Town, tblCustomers.Country
FROM (((tblPOSStocksSold INNER JOIN tblWarehouse ON tblPOSStocksSold.WHID = tblWarehouse.WHID) INNER JOIN (tblPosLineDetails INNER JOIN tblProducts ON tblPosLineDetails.ProductID = tblProducts.ProductID) ON tblPOSStocksSold.ItemSoldID = tblPosLineDetails.ItemSoldID) INNER JOIN tblDocuments ON tblPOSStocksSold.DocID = tblDocuments.DocID) LEFT JOIN tblCustomers ON tblPOSStocksSold.CustomerID = tblCustomers.CustomerID
WHERE (((tblPOSStocksSold.ItemSoldID)=[Forms]![frmPOSStocksSold]![CboReceipts]) AND ((tblPOSStocksSold.rcptNo) Is Not Null));
 
If that's a saved Query then
Code:
If DCount("*","MyQuery") = 0 Then     ' You have no records
    MsgBox"No Data"
    Exit Sub
End iF

'''' Open your report
 
And what happens if the user forgets to "print" the invoice?

I would suggest that you download the "new" Northwinds application and do a deep study of how it handles inventory.
 

Users who are viewing this thread

  • Back
    Top Bottom