Set checkbox default on unload form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to change the default value of a checkbox using code and am
having problems. The following code changes the checked property but when I
start the form up again, the default is back to the original. What am I doing
wrong?

Private Sub Form_Unload(Cancel As Integer)
Dim ctrCheckIt As Control

Set ctrCheckIt = Me.chkTestIt

ctrCheckIt.DefaultValue = False

End Sub
 
Unless you switch the form into design view and save it that way, this
change won't stick. Save the DefaultValue setting into a table, and then
read it from the table and apply it when the form opens.

For an example of how you might set up such a table, save the value there,
and then apply it next time, see:
Return to the same record next time form is opened
at:
http://allenbrowne.com/ser-18.html
 
Back
Top