reset checkboxes to default for all datasets

  • Thread starter Thread starter alexddfd
  • Start date Start date
A

alexddfd

Hi, I have a assumingly simple problem with a small database, but don't
have the time nor nerves to learn all the powers of access. A short
browsing through the access help and this forum didn't help me much, so
I am hoping someone can help me out.

The database is a simple accumulation of address data added with some
extra fields. One of those fields is a checkbox, to serve as a
condition to filter certain datasets.

I am looking for command/macro(?) to assign to a button which resets
the checkbox to default for all datasets and a description, how I apply
this command to the button.

Thnx allot
alexander
 
Hi,


DoCmd.RunSQL "UPDATE tableName SET checkBoxField = TRUE"

or

CurrentDb.Execute "UPDATE tableName SET checkBoxField = TRUE",
dbFailOnError



would reset the mentionned field of the mentionned table to TRUE, ... for
ALL the records of the table. If you are in a form, "bound" to the same
table than the one you are updating, and if, further more, the actual record
is DIRTY, the code you just run would be considered ANOTHER user and an
error would probably occur when YOU will try to save the actual record,
about another user having changed the actual record since you start editing
it. To avoid that kind of problems, be safe, undirty the actual record, or
refuse to run the code if the form is dirty:

If Me.Dirty then
MsgBox"Please, save the actual record before proceeding.",
....
Exit Sub
Else
CurrentDb.Execute "...", dbFailOnError
End If

or

If Me.Dirty Then
Me.Dirty=False ' save the actual record
End If

CurrentDb.Execute "..."




Hoping it may help,
Vanderghast, Access MVP
 
Back
Top