- 帖子
- 8
- 主題
- 3
- 精華
- 0
- 積分
- 11
- 點名
- 0
- 作業系統
- Window 8
- 軟體版本
- OFFICE 2007
- 閱讀權限
- 10
- 性別
- 女
- 註冊時間
- 2014-11-7
- 最後登錄
- 2015-3-11
|
我有一個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
複製代碼 |
|