HELP ON SETTING CHECK BOX VALUE

  • Thread starter Thread starter Guest
  • Start date Start date
TINAKENNEY said:
EVERY TIME FORM OPENS I WANT TO RESET ALL RECORDS CHECK BOX TO FALSE


Dim cnt As Control

For Each cnt In Me.Controls
If cnt.ControlType = acCheckBox Then cnt = False
Next cnt
 
-----Original Message-----
EVERY TIME FORM OPENS I WANT TO RESET ALL RECORDS CHECK BOX TO FALSE
.
There are a few ways to accomplish this but I would
suggest (if ALL the checkbox controls need to go to
false) that you cycle through the control objects on the
form and any that are of type 'checkbox' that you set
their value to false.

Dim ctl As Control

' Enumerate Controls collection.
For Each ctl In frm.Controls
' Check to see if control is check box.
If ctl.ControlType = acCheckBox Then
' Set control properties.
With ctl
.SetFocus
.Value = False
End With
End If
Next ctl


If ALL checkboxes are NOT going to false then you should
create a procedure to check the name of the checkbox
controls and only uncheck those that need to be unchecked.

Hope that helps.

ALAN
 
in
Sshhhh -- no need to shout!
Every time form opens i want to reset all records check box to false

(a) if you set all the fields to false in design mode, then they will stay
that way unless they are bound to fields in the recordset. In that case,
they will reflect the current record which is what you would want, no?

(b) when you say "Every time the form opens", do you really mean the OnOpen
event, that is, only affecting whichever record happens to come first, or
the OnCurrent event, which will affect every record displayed on the form?

(c) if you want all the records to have all these fields set to false, then
it would be easier to do an update query

UPDATE MyTable
SET MyCheckOne = FALSE,
MyCheckTwo = FALSE,
MyCheckThree = FALSE,
MyCheckFour = FALSE,
MyCheckFive = FALSE

(d) If you do have a lot of boolean fields in a table, then it is an odds-
on bet that you would be better off with a major design rethink: see the
AtYourSurvey model.


Hope that helps


Tim F
 
Alan thank you very much for help i wrote following but it only sets first row of form to false any ideas would be very helpful
sorry for earlier "shouting"
Private Sub Form_Current()
Dim cnt As Control
For Each cnt In Form
If cnt.ControlType = acCheckBox Then
With cnt
...SetFocus
...Value = False
End With
End If
Next cnt
End Sub
 
Back
Top