Check and uncheck

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

Guest

I have an optionFrame that contains two check boxes,if i check one of them
and close the form,when i open the form again both of them are unchecked.

I there a way that,whenever i check one of these two check boxes they
remain to be checked even after closing the database ?

Regards
 
Pietro said:
I have an optionFrame that contains two check boxes,if i check one
of them and close the form,when i open the form again both of them
are unchecked.

I there a way that,whenever i check one of these two check boxes they
remain to be checked even after closing the database ?

Regards

Changes to unbound controls have no place to be saved. If you want data to
persist then you should store it in a table.
 
Hi Pietro

If the option group is bound to a field in your form's record source, then
the checkbox corresponding to the stored value will be checked when you
display a given record.

It sounds like your option group is unbound, which means that it will show
the option group's default value when you open the form. If the default
value is null (looks like blank) then the option group will be set to Null
and both checkboxes will be grey and neither of them checked.

If you want the form to "remember" the last setting, then you must store it
somewhere. This could be in a file, or the registry, or a database
property, or most commonly in a table. For example, you could have a table
named "Settings" with a numeric field "SavedOption". The table should have
exactly one record (you can add other fields for other settings).

Then, set the default value of your option group to:
=DLookup("SavedOption", "Settings")

Finally, you need to save the option to the table whenever the user clicks
the other box, so add an AfterUpdate event procedure for your option group:

Private Sub YourOptionGroup_AfterUpdate()
Dim sSQL as string
sSQL = "Update Settings set SavedOption = " & YourOptionGroup
CurrentDb.Execute sSQL
End Sub

I hope this gives you the general idea :-)
 
Back
Top