我有一種情況,我只需要在連續表單上將一個 ID 設定為默認值。這樣做似乎并不容易。請看一下附圖,它允許我選擇多個。我試過單選按鈕,它也不起作用

uj5u.com熱心網友回復:
您可以回圈RecordsetClone表單:
Private Sub IsDefault_AfterUpdate()
Dim rs As DAO.Recordset
If Me.Dirty Then
Me.Dirty = False
End If
If Me!IsDefault.Value = True Then
' Deselect other records.
Set rs = Me.RecordsetClone
rs.MoveFirst
While Not rs.EOF
If rs!Id.Value <> Me!Id.Value Then
If rs!IsDefault.Value = True Then
rs.Edit
rs!IsDefault.Value = False
rs.Update
End If
End If
rs.MoveNext
Wend
rs.Close
Me!SomeOtherControl.SetFocus
Me!IsDefault.Enabled = False
Me!IsDefault.Locked = True
End If
End Sub
Private Sub Form_Current()
Dim Ready As Boolean
Dim NewRecord As Boolean
NewRecord = Me.NewRecord
If NewRecord Then
Me!IsDefault.DefaultValue = Not CBool(Me.RecordsetClone.RecordCount)
Me!SomeOtherControl.SetFocus
Else
Ready = Not Me!IsDefault.Value
End If
' The selected record cannot be deselected.
' Deselect by selecting another record.
Me!IsDefault.Enabled = Ready
Me!IsDefault.Locked = Not Ready
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/497025.html
上一篇:ms-access運行時錯誤3075額外)在vbasql
下一篇:參考訪問表中的單元格
