H
hermanko
Hi,
I have a form [Duplication] which has two subforms, [Sub1] and [Sub2].
Each subform contains records that the user can select to remove by
first selecting the record's associated checkbox (a yes/no field), and
then clicking on a Command button "cmd_remove" on the Duplication form.
The tricky part is that I need the cmd button disabled when no
checkboxes are selected in both subforms, and enabled if any ONE box is
selected from EITHER subform.
I used the following code under each subform's checkbox control
AfterUpdate event. It is the same for both subforms:
Private Sub Yes_No_AfterUpdate()
Dim rsClone As Recordset
Dim blnChecked As Boolean
Me.Dirty = False
Set rsClone = Me.RecordsetClone
rsClone.MoveFirst
Do Until rsClone.EOF
If rsClone![Yes/No] Then
blnChecked = True
Exit Do
End If
rsClone.MoveNext
Loop
[Forms]![Duplication]!cmd_remove.Enabled = blnChecked
Set rsClone = Nothing
End Sub
The problem with this code is that the cmd button reacts fine but
dependantly to each subform. i.e. if i check a box from Sub1 as well as
Sub2, the cmd button enables correctly, but once i clear all boxes
from, say, Sub1, the cmd button disables even tho there are still
selected boxes from Sub2. I need to get the code to check both
recordsets on each AfterUpdate event for both subforms.
any suggestions would be greatly appreciated, as my vb is not strong.
Thanks!
Herman
I have a form [Duplication] which has two subforms, [Sub1] and [Sub2].
Each subform contains records that the user can select to remove by
first selecting the record's associated checkbox (a yes/no field), and
then clicking on a Command button "cmd_remove" on the Duplication form.
The tricky part is that I need the cmd button disabled when no
checkboxes are selected in both subforms, and enabled if any ONE box is
selected from EITHER subform.
I used the following code under each subform's checkbox control
AfterUpdate event. It is the same for both subforms:
Private Sub Yes_No_AfterUpdate()
Dim rsClone As Recordset
Dim blnChecked As Boolean
Me.Dirty = False
Set rsClone = Me.RecordsetClone
rsClone.MoveFirst
Do Until rsClone.EOF
If rsClone![Yes/No] Then
blnChecked = True
Exit Do
End If
rsClone.MoveNext
Loop
[Forms]![Duplication]!cmd_remove.Enabled = blnChecked
Set rsClone = Nothing
End Sub
The problem with this code is that the cmd button reacts fine but
dependantly to each subform. i.e. if i check a box from Sub1 as well as
Sub2, the cmd button enables correctly, but once i clear all boxes
from, say, Sub1, the cmd button disables even tho there are still
selected boxes from Sub2. I need to get the code to check both
recordsets on each AfterUpdate event for both subforms.
any suggestions would be greatly appreciated, as my vb is not strong.
Thanks!
Herman