I want to build a check up query that checks two fields, the so called Saldo ad Stock for each affiliate and after that to issue a message enumerating the affiliates where the figures in Saldo and Stock do not match.Can you help?
My idea is to check for each office, but how to do it in the code ?
Public Function BatchCheckUp() ' check the difference between Saldo and Stcok for each office and at
'the end make alist with the offices where there is a discrepancy.
Dim StrSQL As String
Dim StrOffice As Integer
Dim StrItems As Integer
' cary out the check up for each office
' First office
StrOffice = 1
StrItems = 0
' Second office
StrOffice = 2
StrItems = 1
StrSQL = " SELECT qryCrosstab.ProductID, Sum(qryCrosstab.[-1]) AS [SumOf-1], Sum(qryCrosstab.[0]) AS SumOf0, [SumOf-1]-[SumOf0] AS Saldo, products.items6 AS stock" & _
" FROM qryCrosstab INNER JOIN products ON qryCrosstab.ProductID = products.Productid " & _
" WHERE (((qryCrosstab.afid) = = " & InOffice & "))" & _
" GROUP BY qryCrosstab.ProductID, products.items= " & InItems & ";"
CurrentDb.Execute StrSQL
End Function
But how should the query check and send the message ?
There could be several products for an office (affiliate) for which Saldo doesn't equal Stock.But in my case i need to build a quick check up from bird's view and to establish in which offices something is not in order. Regarldess if one or more products are concerned.We need to eliminate the offices where everything is ok.And, we expect, in the future everything will be OK, so our employees will save time only by clicking on the button and geting the information that everything is Ok ( hopefully).
My idea is to check for each office, but how to do it in the code ?
Public Function BatchCheckUp() ' check the difference between Saldo and Stcok for each office and at
'the end make alist with the offices where there is a discrepancy.
Dim StrSQL As String
Dim StrOffice As Integer
Dim StrItems As Integer
' cary out the check up for each office
' First office
StrOffice = 1
StrItems = 0
' Second office
StrOffice = 2
StrItems = 1
StrSQL = " SELECT qryCrosstab.ProductID, Sum(qryCrosstab.[-1]) AS [SumOf-1], Sum(qryCrosstab.[0]) AS SumOf0, [SumOf-1]-[SumOf0] AS Saldo, products.items6 AS stock" & _
" FROM qryCrosstab INNER JOIN products ON qryCrosstab.ProductID = products.Productid " & _
" WHERE (((qryCrosstab.afid) = = " & InOffice & "))" & _
" GROUP BY qryCrosstab.ProductID, products.items= " & InItems & ";"
CurrentDb.Execute StrSQL
End Function
But how should the query check and send the message ?
There could be several products for an office (affiliate) for which Saldo doesn't equal Stock.But in my case i need to build a quick check up from bird's view and to establish in which offices something is not in order. Regarldess if one or more products are concerned.We need to eliminate the offices where everything is ok.And, we expect, in the future everything will be OK, so our employees will save time only by clicking on the button and geting the information that everything is Ok ( hopefully).