Access.2007.VBA.Bibl..

(John Hannent) #1
strSaveNameAndPath = strDocsPath & strSaveName
Debug.Print “Save name: “ & strSaveName

On Error Resume Next

Check for the existence of a file with this name, and delete it if found:


Set fil = fso.GetFile(strSaveNameAndPath)
If Not fil Is Nothing Then
Kill strSaveNameAndPath
End If

On Error GoTo ErrorHandler
doc.SaveAs FileName:=strSaveNameAndPath

Update the progress meter:


Application.SysCmd acSysCmdUpdateMeter, lngSet

Update the ReadyToShip field in tblOrders to False:


DoCmd.SetWarnings False
strSQL = “UPDATE tblOrders SET “ _
& “tblOrders.ReadyToShip = False “ _
& “WHERE OrderID = “ & lngOrderID
Debug.Print “SQL string: “ & strSQL
DoCmd.RunSQL strSQL

Subtract the amount of product shipped from the in stock amount in tblProducts:


lngSubtract = lngCasesInStock - lngNoCases
strSQL = “UPDATE tblProducts SET “ _
& “tblProducts.UnitsInStock = “ _
& lngSubtract & “ WHERE ProductID = “ _
& lngProductID
Debug.Print “SQL string: “ & strSQL
DoCmd.RunSQL strSQL

In tblOrderDetails, set QuantityShipped to QuantityOrdered, and DateShipped to today’s date:


strSQL = “UPDATE tblOrderDetails SET “ _
& “tblOrderDetails.QuantityShipped = “ _
& “[QuantityOrdered], “ _
& “tblOrderDetails.DateShipped = Date() “ _
& “WHERE tblOrderDetails.OrderID = “ _
& lngOrderID _
& “ And tblOrderDetails.ProductID = “ _
& lngProductID & “;”
Debug.Print “SQL string: “ & strSQL
DoCmd.RunSQL strSQL

Going Beyond the Basics 12

Free download pdf