標題:
[發問]
Help!數量與庫存之間的驗證問題
[打印本頁]
作者:
hildaliu
時間:
2015-3-7 00:28
標題:
Help!數量與庫存之間的驗證問題
我有一個input box 來輸入數量
但我的代碼只對數量和庫存的限制不起作用
如果數量>庫存數量
input box會一直循環
如果庫存水平是200
我輸入50,但input還是循環
我不知道我的代碼做錯了什麼
Do
Myquantity = InputBox("Please Specify the Quantity of ProductID." _
& Me.ProductID & vbCr & "")
If (Myquantity <> "") Then Q = ValidateQ(Myquantity)
Loop While (Q = False) Or (Myquantity = "") Or (Myquantity = "0") Or (Myquantity > Me.Stock_level)
Forms![F_Orders].[F_Order_line_subform].SetFocus
DoCmd.GoToRecord , , acLast
Me.Parent.F_Order_line_subform.Form!Quantity = Myquantity
MsgBox "The order of ProductID." _
& Me.ProductID & vbCr & "successfully added to order"
複製代碼
Function ValidateQ(Myquantity As String) As Boolean
Dim strLength As Integer
Dim I As Integer
Myquantity = Trim(Myquantity)
strLength = Len(Myquantity)
For I = 1 To strLength
If Myquantity = "0" Then
ValidateQ = False
msb = MsgBox("Invalid values, this values is not allow to enter , try again", vbCritical, "Error")
Else
ValidateQ = True
End If
Next I
If (Myquantity <> "") Then
If IsNumeric(Myquantity) Then
ValidateQ = True
Else
ValidateQ = False
msb = MsgBox("invalid values,PLease enter a Numeric values ", vbCritical, "Error")
End If
End If
End Function
複製代碼
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)