Posted By

cdevitt on 04/20/10


Tagged


Versions (?)

checkbox message for barcode.


 / Published in: VB.NET
 

  1. Private Sub txtBarcode_AfterUpdate()
  2. If Nz(txtBarcode.Value) = "" Then
  3. MsgBox "Barcode is required...", vbExclamation, "Oops!"
  4.  
  5. ElseIf DCount("Barcode", "tblInventoryInformation", "[Barcode]=" & Me.txtBarcode) > 0 Then
  6. MsgBox "This barcode already exists!", vbCritical, "Error!"
  7. txtBarcode.Value = Null
  8. Cancel = True
  9. End If
  10. End Sub
  11.  
  12.  
  13.  
  14. Private Sub chkITRelated_AfterUpdate()
  15. Dim stDocName As String
  16. Dim stLinkCriteria As String
  17. Dim intAnswer As Integer
  18. Dim strSQL As String
  19. stDocName = "frmITRelated"
  20. stLinkCriteria = "[Barcode]=" & Me![txtBarcode]
  21.  
  22.  
  23. If Nz(txtBarcode.Value) = "" Then
  24. MsgBox "Barcode is required...", vbExclamation, "Oops!"
  25. chkITRelated.Value = False
  26. Me.txtBarcode.SetFocus
  27. If chkITRelated.Value = True Then
  28. If DCount("*", "tblITRelated", stLinkCriteria) = 0 Then
  29. intAnswer = MsgBox("The barcode was not found!" & vbCrLf & "Would you like to add it to the IT Related table now?", vbQuestion + vbYesNo, "Hello World!")
  30. If intAnswer = vbYes Then
  31. strSQL = "INSERT INTO tblITRelated([Barcode])" & "VALUES ([txtBarcode]);"
  32. DoCmd.SetWarnings False
  33. DoCmd.RunSQL strSQL
  34. DoCmd.SetWarnings True
  35. MsgBox "The barcode has been added!", vbInformation, "Great Success!"
  36. Response = acDataErrAdded
  37. DoCmd.OpenForm stDocName, , , stLinkCriteria
  38. ElseIf intAnswer = vbNo Then
  39. MsgBox "Clearing IT Related checkbox...", vbInformation, "Oh noes!"
  40. chkITRelated.Value = False
  41. Response = acDataErrContinue
  42. End If
  43. Else
  44. DoCmd.OpenForm stDocName, , , stLinkCriteria
  45. End If
  46. End If
  47. End If
  48. LastUpdated.Value = (Now())
  49. End Sub

Report this snippet  

You need to login to post a comment.