Using Check boxes to set a 'Default' value

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

Guest

I have a table of values and would like to set one of them as a default
I have added a Yes/No field to the table to do this.
On the form, is there a way of making only one selection True (i.e. set all others to False)
I have tried using a recordset, but it isn't working. (see below

Private Sub Default_Click(
Dim rst As Recordse
Dim ID As Lon

ID = RecordI

Set rst = Me.Recordse
Do While Not rst.EO
If rst!ID <> ID The
rst.Edi
rst!Default = Fals
rst.Updat
End I
rst.MoveNex
Loo
Set rst = Nothin

End Su
 
What about using an option box instead of the check boxes? Then, when the one value is chosen as true, you can set the value of the Yes/No fields

If Me.OptionBox = 1 the
[checkBox1]= Tru
[CheckBox2]=Fals
[CheckBox3]=Fals
[CheckBox4]=Fals
and continue with the other three options. This would limit to one true value



----- Nik wrote: ----

I have a table of values and would like to set one of them as a default
I have added a Yes/No field to the table to do this.
On the form, is there a way of making only one selection True (i.e. set all others to False)
I have tried using a recordset, but it isn't working. (see below

Private Sub Default_Click(
Dim rst As Recordse
Dim ID As Lon

ID = RecordI

Set rst = Me.Recordse
Do While Not rst.EO
If rst!ID <> ID The
rst.Edi
rst!Default = Fals
rst.Updat
End I
rst.MoveNex
Loo
Set rst = Nothin

End Su
 
How about using an update query on the table? Just set up a button on
the form to run the query on all the records and set them to No, then
click on the checkbox control of the one you want as the default.

Russ
 
Thanks for the pointer Russ -
I have got it working with the following
Mouse Down event -- Apply the update query to force all values to fals
Mouse Up event -- Set the check box value to Tru

It works a treat
 
Back
Top