Hello all,
I need help with the Input Box and CancelEvent.
The following is a function that I made.
The point of all is that over the function Input Box it is import into a Sken table.
At the same time, I need help how to stop import before if validation fails.
I put the command CancelEvent but not work.
So we need to suspend import if you do not pass validation.
If the validation does not pass puts the message "Do you want to delete the scanned barcode"
Private Sub Command0_Click()
DoCmd.SetWarnings False
Dim Barkod As String
Barkod = "?"
While Barkod = "?"
DoCmd.Requery
Barkod = InputBox("Unesi barkod", "Barkod", , 1, 15)
If Barkod <> "" Then
CurrentDb.Execute "INSERT INTO Sken VALUES ('" & Barkod & "');"
Me.Refresh
Barkod = "?"
If IsNull(Forms![FrmZaprimanje2]![SubZaprimanje].Form![Artikl]) Then
Dim MyAnswer As Integer
MyAnswer = vbCancel
Do While MyAnswer = vbCancel
MyAnswer = MsgBox("Scanned barcode is not in database", vbOKCancel + vbInformation + vbDefaultButton2, "Information")
Loop
If MsgBox("Do you want to delete the scanned barcode?", vbOKCancel + vbCritical + vbDefaultButton1, "Delete article") = vbOK Then
DoCmd.CancelEvent
DoCmd.Requery
Me.Refresh
End If
End If
End If
Wend
End Sub
I need help with the Input Box and CancelEvent.
The following is a function that I made.
The point of all is that over the function Input Box it is import into a Sken table.
At the same time, I need help how to stop import before if validation fails.
I put the command CancelEvent but not work.
So we need to suspend import if you do not pass validation.
If the validation does not pass puts the message "Do you want to delete the scanned barcode"
Private Sub Command0_Click()
DoCmd.SetWarnings False
Dim Barkod As String
Barkod = "?"
While Barkod = "?"
DoCmd.Requery
Barkod = InputBox("Unesi barkod", "Barkod", , 1, 15)
If Barkod <> "" Then
CurrentDb.Execute "INSERT INTO Sken VALUES ('" & Barkod & "');"
Me.Refresh
Barkod = "?"
If IsNull(Forms![FrmZaprimanje2]![SubZaprimanje].Form![Artikl]) Then
Dim MyAnswer As Integer
MyAnswer = vbCancel
Do While MyAnswer = vbCancel
MyAnswer = MsgBox("Scanned barcode is not in database", vbOKCancel + vbInformation + vbDefaultButton2, "Information")
Loop
If MsgBox("Do you want to delete the scanned barcode?", vbOKCancel + vbCritical + vbDefaultButton1, "Delete article") = vbOK Then
DoCmd.CancelEvent
DoCmd.Requery
Me.Refresh
End If
End If
End If
Wend
End Sub