Guest User

Untitled

a guest
May 24th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Compare Database
  2.  
  3. ' /**
  4. '  * @author Jia Jian
  5. '  */
  6.  
  7.  
  8. 'variable declarations
  9. Dim db As DAO.Database
  10. Dim rs As DAO.Recordset
  11.  
  12. ' same as declaring int rsCount; in Java
  13. Dim rsCount As Integer
  14.  
  15.  
  16. Dim Response, Action
  17.  
  18.  
  19. Public Function checkInventory()
  20.  
  21.     Set db = CurrentDb
  22.     Set rs = db.OpenRecordset("Low on Stock")
  23.    
  24.     rsCount = rs.RecordCount
  25.    
  26.     rs.MoveFirst
  27.    
  28.     If rsCount > 0 Then
  29.         Response = MsgBox("You have some items/products that are about to run out of stock!" & vbNewLines & "Would you like to see which are the items that are going to run out of stock?", vbYesNo + vbInformation + vbDefaultButton4, "Inventory Check!")
  30.        
  31.         If Response = vbYes Then
  32.             ' Macro to open the report.
  33.            DoCmd.RunMacro ("Open Low on Stock Report")
  34.         Else
  35.             ' Do nothing
  36.        End If
  37.     Else
  38.         Action = MsgBox("There are no items/products that are low on stock!", vbInformation, "Inventory Check!")
  39.     End If
Add Comment
Please, Sign In to add comment