我有一個訪問表,其中存盤有關在產品上完成的步驟的資訊。輸入資訊時,我會彈出一個表單,詢問他們要為哪個產品輸入資料。表中的每條記錄都有自己的復選框(動態創建)。如果已經為該產品記錄了資訊,那么對于該步驟,該復選框將被禁用。當所有復選框都被禁用時,我會彈出一個訊息框,說明該步驟的所有產品都已完成。
問題:無論出于何種原因(運營商選擇、生產原因等),產品 4 的作業已完成訂單但未在 1、2、3 上完成。我所說的所有產品都輸入了資訊只是因為這是檢查的最后一條記錄。
Dim Args As Variant
Dim i As Integer
Dim ctl As Control
Dim bCheck As Boolean
bCheck = False
If Not IsNull(Me.OpenArgs) Then
Args = Split(Me.OpenArgs, ";")
Me.txtForm = Args(0)
Me.lblChoices.Caption = Args(1)
End If
For Each ctl In Forms(Me.Name).Controls
If ctl.ControlType = acCheckBox Then
ctl.Value = False
If ctl.Enabled = True Then
bCheck = False
Else
bCheck = True
End If
End If
Next
If bCheck = True Then
fncMsgBox "Labor has been entered for all bundles on this step."
DoCmd.Close acForm, Me.Name
End If
這個 IF 陳述句是問題所在,對我來說很明顯為什么它不起作用。我很好奇如何解決這個問題?
If ctl.Enabled = True Then
bCheck = False
Else
bCheck = True
End If

uj5u.com熱心網友回復:
找到啟用的復選框后立即退出回圈:
Dim Args As Variant
Dim i As Integer
Dim ctl As Control
Dim bCheck As Boolean
bCheck = False
If Not IsNull(Me.OpenArgs) Then
Args = Split(Me.OpenArgs, ";")
Me.txtForm = Args(0)
Me.lblChoices.Caption = Args(1)
End If
For Each ctl In Forms(Me.Name).Controls
If ctl.ControlType = acCheckBox Then
ctl.Value = False
If ctl.Enabled Then
bCheck = True
Exit For 'stop checking
End If
End If
Next
If bCheck Then
fncMsgBox "Labor has been entered for all bundles on this step."
DoCmd.Close acForm, Me.Name
End If
注意:當您檢查的值已經代表布林值時,= True您不需要 。If
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/416194.html
標籤:
上一篇:Chrome控制臺中的Web抓取-遍歷mat-tab元素中的行
下一篇:MSAccess中的編號
