type mismatch
-
i am trying to perform form validation on my Order Generation form. In testing for a valid quantity, i use the following if statements ElseIf (Me.txtQuantity.Text = "") Then MsgBox "Please enter a value for Quantity" ElseIf Val(iQuantity) = 0 Then MsgBox "Please enter a value for Product code" ElseIf IsNumeric(iQuantity) = False MsgBox "Please enter a value for Product code" However, is doesnt seem to recognize these statements as when i dont enter a value for quantity, a message box should pop up but instead i hit a runtime error saying "type mismatch"...why is this - is there anything i can do about it? Thank you in advance!
-
i am trying to perform form validation on my Order Generation form. In testing for a valid quantity, i use the following if statements ElseIf (Me.txtQuantity.Text = "") Then MsgBox "Please enter a value for Quantity" ElseIf Val(iQuantity) = 0 Then MsgBox "Please enter a value for Product code" ElseIf IsNumeric(iQuantity) = False MsgBox "Please enter a value for Product code" However, is doesnt seem to recognize these statements as when i dont enter a value for quantity, a message box should pop up but instead i hit a runtime error saying "type mismatch"...why is this - is there anything i can do about it? Thank you in advance!
I'd recommend the following: - create a local variable based on a Trim() of the txtQuantity.Text - check length first - next, check for a false on IsNumeric() - only then look for certain integer values HTH limit further bugs btw, which line are you getting the type mismatch from? Cheers, Simon "The day I swan around in expensive suits is the day I hope someone puts a bullet in my head.", Chris Carter.
my svg article