/ Published in: VB.NET
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Private Sub chkITRelated_AfterUpdate() Dim stDocName As String Dim stLinkCriteria As String Dim intAnswer As Integer Dim strSQL As String stDocName = "frmITRelated" stLinkCriteria = "[Barcode]=" & Me![Barcode] If chkITRelated.Value = True Then Me.btnEditITData.Visible = True If DCount("*", "tblITRelated", stLinkCriteria) = 0 Then intAnswer = MsgBox("The barcode was not found!" & vbCrLf & "Would you like to add it to the IT Related table now?", vbExclamation + vbYesNo, "Error!") If intAnswer = vbYes Then strSQL = "INSERT INTO tblITRelated([Barcode])" & "VALUES ([Barcode]);" DoCmd.SetWarnings False DoCmd.RunSQL strSQL DoCmd.SetWarnings True MsgBox "The barcode has been added!", vbInformation, "Great Success!" Response = acDataErrAdded DoCmd.OpenForm stDocName, , , stLinkCriteria ElseIf intAnswer = vbNo Then MsgBox "Clearing IT Related checkbox...", vbInformation, "Oh noes!" chkITRelated.Value = False Response = acDataErrContinue End If 'ElseIf 'DoCmd.OpenForm stDocName, , , stLinkCriteria End If Else Me.btnEditITData.Visible = False End If End Sub