D
DocBrown
I have a continuous form which has controls setup so I can select specific
records. This code is based on the excellent answer given by Albert D.Kallal
long ago. The following is the OnClick code for the command button:
Dim colCheckBox As New Collection
Public Function IsChecked(vID As Variant) As Boolean
Dim lngID As Long
IsChecked = False
On Error GoTo exit1
lngID = colCheckBox(CStr(vID))
If lngID <> 0 Then
IsChecked = True
End If
exit1:
End Function
Private Sub cmdSelectRec_Click()
If IsChecked(Me.txtVolunteerID) = False Then
colCheckBox.Add CLng(Me.txtVolunteerID), CStr(Me.txtVolunteerID)
Else
colCheckBox.Remove (CStr(Me.txtVolunteerID))
End If
Me.chkSelectRec.Requery
End Sub
There is also toggle button togSelectRec that has it's Control Source set
to: =IsChecked([Volunteerid])
There is also a chkSelectRec checkbox Control Source is also set to this.
(I'm working to substitue the Toggle button for the action of the checkbox.)
The Control Source function causes the control to display whether the record
has been added to the collection.
This works except for an anomally where when the cmd is clicked, all check
boxes (or the toggles) clear then get set to their proper value. This is
disturbing. BUT if I direct the requery to ANOTHER checkbox on the form that
control does the clear/set action AND the chkSelectRec or togSelectRec get
their proper values WITHOUT that clear/set.
What's going on and can I get the requery to work without that clear/set
anomally? Why is a requery to ANY control on the form causing the
chkSelectRec and togSelectRec controls to get their proper values?
BTW, if I remove the Control source call from chkSelectRec, the togSelectRec
still gets set correctly without the clear/set even if the requery is to the
togSelectRec (of course now the chkbox doesn't get set.)
I know this is subtile but any help is appreciated.
Thanks,
John
records. This code is based on the excellent answer given by Albert D.Kallal
long ago. The following is the OnClick code for the command button:
Dim colCheckBox As New Collection
Public Function IsChecked(vID As Variant) As Boolean
Dim lngID As Long
IsChecked = False
On Error GoTo exit1
lngID = colCheckBox(CStr(vID))
If lngID <> 0 Then
IsChecked = True
End If
exit1:
End Function
Private Sub cmdSelectRec_Click()
If IsChecked(Me.txtVolunteerID) = False Then
colCheckBox.Add CLng(Me.txtVolunteerID), CStr(Me.txtVolunteerID)
Else
colCheckBox.Remove (CStr(Me.txtVolunteerID))
End If
Me.chkSelectRec.Requery
End Sub
There is also toggle button togSelectRec that has it's Control Source set
to: =IsChecked([Volunteerid])
There is also a chkSelectRec checkbox Control Source is also set to this.
(I'm working to substitue the Toggle button for the action of the checkbox.)
The Control Source function causes the control to display whether the record
has been added to the collection.
This works except for an anomally where when the cmd is clicked, all check
boxes (or the toggles) clear then get set to their proper value. This is
disturbing. BUT if I direct the requery to ANOTHER checkbox on the form that
control does the clear/set action AND the chkSelectRec or togSelectRec get
their proper values WITHOUT that clear/set.
What's going on and can I get the requery to work without that clear/set
anomally? Why is a requery to ANY control on the form causing the
chkSelectRec and togSelectRec controls to get their proper values?
BTW, if I remove the Control source call from chkSelectRec, the togSelectRec
still gets set correctly without the clear/set even if the requery is to the
togSelectRec (of course now the chkbox doesn't get set.)
I know this is subtile but any help is appreciated.
Thanks,
John