Posted By

cdevitt on 04/19/10


Tagged

access


Versions (?)

MsgBox if statement


 / Published in: VB.NET
 

  1. Private Sub chkITRelated_AfterUpdate()
  2. Dim stDocName As String
  3. Dim stLinkCriteria As String
  4. Dim intAnswer As Integer
  5. Dim strSQL As String
  6. stDocName = "frmITRelated"
  7. stLinkCriteria = "[Barcode]=" & Me![Barcode]
  8.  
  9. If chkITRelated.Value = True Then
  10. Me.btnEditITData.Visible = True
  11. If DCount("*", "tblITRelated", stLinkCriteria) = 0 Then
  12. intAnswer = MsgBox("The barcode was not found!" & vbCrLf & "Would you like to add it to the IT Related table now?", vbExclamation + vbYesNo, "Error!")
  13. If intAnswer = vbYes Then
  14. strSQL = "INSERT INTO tblITRelated([Barcode])" & "VALUES ([Barcode]);"
  15. DoCmd.SetWarnings False
  16. DoCmd.RunSQL strSQL
  17. DoCmd.SetWarnings True
  18. MsgBox "The barcode has been added!", vbInformation, "Great Success!"
  19. Response = acDataErrAdded
  20. DoCmd.OpenForm stDocName, , , stLinkCriteria
  21. ElseIf intAnswer = vbNo Then
  22. MsgBox "Clearing IT Related checkbox...", vbInformation, "Oh noes!"
  23. chkITRelated.Value = False
  24. Response = acDataErrContinue
  25. End If
  26. 'ElseIf
  27. 'DoCmd.OpenForm stDocName, , , stLinkCriteria
  28. End If
  29. Else
  30. Me.btnEditITData.Visible = False
  31. End If
  32. End Sub

Report this snippet  

You need to login to post a comment.