Guest User

ShippingBox

a guest
May 18th, 2012
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Sub Save_Click()
  5.  
  6. Dim CurrentConcat As String
  7. Dim PastConcat As String
  8. Dim PastConcatGrab As Boolean
  9. Dim txtbox As String
  10.  
  11.  
  12. Dim PastPrice As Currency
  13. Dim ExpPrice As Currency
  14.  
  15.  
  16. CurrentConcat = Me!CurrentConcat 'Set current Concatenated ID to the ID on the form
  17.  
  18. PastConcatGrab = IsNull(DLookup("[CalConcatID]", "qryBoxHistory", "[CalConcatID] = CurrentConcat"))
  19.  
  20.     If PastConcatGrab = True Then 'If lookup shows that no boxes have been entered under that ID then a message is displayed and the values saved
  21.        txtbox = MsgBox("This is a new box, no past prices exist", vbOKOnly, "Information")
  22.         DoCmd.RunCommand acCmdSaveRecord
  23.     Else
  24.         PastConcat = DLookup("[CalConcatID]", "qryBoxHistory", "[CalConcatID] = CurrentConcat")
  25.         PastPrice = DMin([qryBoxHistory]![Price Each], "qryBoxHistory", "[CalConcatID] = 133377")
  26.         ExpPrice = Me![Price]
  27.         If ExpPrice > PastPrice Then
  28.             txtbox = MsgBox("This Box is not being supplied at a discounted rate, box has NOT been saved", vbOKOnly, "Information")
  29.         Else
  30.             txtbox = MsgBox("This box is discounted, This price has been saved", vbOKOnly, "Information")
  31.         End If
  32. End If
  33. End Sub
Advertisement
Add Comment
Please, Sign In to add comment