Return to Snippet

Revision: 26205
at April 20, 2010 16:43 by cdevitt


Initial Code
Private Sub txtBarcode_AfterUpdate()
If Nz(txtBarcode.Value) = "" Then
MsgBox "Barcode is required...", vbExclamation, "Oops!"

ElseIf DCount("Barcode", "tblInventoryInformation", "[Barcode]=" & Me.txtBarcode) > 0 Then
MsgBox "This barcode already exists!", vbCritical, "Error!"
txtBarcode.Value = Null
Cancel = True
End If
End Sub



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![txtBarcode]
    
    
    If Nz(txtBarcode.Value) = "" Then
        MsgBox "Barcode is required...", vbExclamation, "Oops!"
        chkITRelated.Value = False
        Me.txtBarcode.SetFocus
            If chkITRelated.Value = True Then
                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?", vbQuestion + vbYesNo, "Hello World!")
                    If intAnswer = vbYes Then
                        strSQL = "INSERT INTO tblITRelated([Barcode])" & "VALUES ([txtBarcode]);"
                        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
                Else
                    DoCmd.OpenForm stDocName, , , stLinkCriteria
                End If
            End If
    End If
LastUpdated.Value = (Now())
End Sub

Initial URL

                                

Initial Description

                                

Initial Title
checkbox message for barcode.

Initial Tags

                                

Initial Language
VB.NET