If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Using Check boxes to set a 'Default' value
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 Recordset Dim ID As Long ID = RecordID Set rst = Me.Recordset Do While Not rst.EOF If rst!ID ID Then rst.Edit rst!Default = False rst.Update End If rst.MoveNext Loop Set rst = Nothing End Sub |
#2
|
|||
|
|||
Using Check boxes to set a 'Default' value
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 then [checkBox1]= True [CheckBox2]=False [CheckBox3]=False [CheckBox4]=False 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 Recordset Dim ID As Long ID = RecordID Set rst = Me.Recordset Do While Not rst.EOF If rst!ID ID Then rst.Edit rst!Default = False rst.Update End If rst.MoveNext Loop Set rst = Nothing End Sub |
#3
|
|||
|
|||
Using Check boxes to set a 'Default' value
Unfortunately, That won't work as I only have one check box per record.
|
#4
|
|||
|
|||
Using Check boxes to set a 'Default' value
Sorry, I went the wrong direction on that.
|
#5
|
|||
|
|||
Using Check boxes to set a 'Default' value
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 On Thu, 3 Jun 2004 08:26:07 -0700, 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 Recordset Dim ID As Long ID = RecordID Set rst = Me.Recordset Do While Not rst.EOF If rst!ID ID Then rst.Edit rst!Default = False rst.Update End If rst.MoveNext Loop Set rst = Nothing End Sub |
#6
|
|||
|
|||
Using Check boxes to set a 'Default' value
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 false Mouse Up event -- Set the check box value to True It works a treat |
Thread Tools | |
Display Modes | |
|
|