Checboxes will not clear on close

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

I am trying to use a code found in this message board but am unable to get to
clear when form is closed. I do have this code in the "on close" in form
properties. Dim ctl As Access.Control
For Each ctl In Me.Controls
If (ctl.ControlType = acCheckBox) Then
ctl.Value = Null
End If
Next ctl
I select the checkboxes that run a query/report. If I do not run the report
the check boxes selected will clear but if I run the report and then close
the form only the last checkboxes will clear and the (ctl.Value = Null)
will be highlited in VBA window.
 
Are the check boxes bound to a field in your table, or unbound?

If bound to a yes/no field in an Access (JET) table, then:

a) You will not be able to set them to Null.
JET does not support Null in Yes/No fields.

b) The close event of a form is too late to change the value.

If unbound, then there is no point clearing them. The value is not going
anywhere, since the form is closing. It would make more sense to initialize
them next time the form opens (or just give the the desired Default Value.)
 
Back
Top