A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Using Check boxes to set a 'Default' value



 
 
Thread Tools Display Modes
  #1  
Old June 3rd, 2004, 04:26 PM
Nik
external usenet poster
 
Posts: n/a
Default 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  
Old June 3rd, 2004, 04:51 PM
Jackie L.
external usenet poster
 
Posts: n/a
Default 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  
Old June 3rd, 2004, 05:41 PM
Nik
external usenet poster
 
Posts: n/a
Default Using Check boxes to set a 'Default' value

Unfortunately, That won't work as I only have one check box per record.
  #4  
Old June 3rd, 2004, 07:11 PM
Jackie L.
external usenet poster
 
Posts: n/a
Default Using Check boxes to set a 'Default' value

Sorry, I went the wrong direction on that.

  #5  
Old June 5th, 2004, 01:40 AM
Russ
external usenet poster
 
Posts: n/a
Default 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  
Old June 9th, 2004, 11:56 AM
Nik
external usenet poster
 
Posts: n/a
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:06 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.