Using Check boxes to set a 'Default' value

N

Nik

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
 
J

Jackie L.

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
 
R

Russ

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
 
N

Nik

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top