I have a combobox in a user form for quantities to be entered. The quantities can only be numbers through the use of the following keypress macro:
However when it is being submitted, the entry can be '0' and still register. How can I prevent a value of zero from being accepted? I have tried the following but it doesn't work as the entry gets published to the workbook anyways:
VBA Code:
Private Sub CaseQty_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If (KeyAscii > 47 And KeyAscii < 58) Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Please only use numbers for case quantities.", vbOKOnly + vbInformation, "Invalid Entry"
End If
End Sub
However when it is being submitted, the entry can be '0' and still register. How can I prevent a value of zero from being accepted? I have tried the following but it doesn't work as the entry gets published to the workbook anyways:
VBA Code:
ElseIf OrderEntry.CaseQty = 0 Then
OrderEntry.CaseQty.Value = ""
OrderEntry.CaseQty.SetFocus
msgValue = MsgBox("Please enter a number greater than '0' for the Cases.", vbOKOnly + vbInformation, "Missing Information")
Exit Sub