BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

One and only one record checked in table

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop)
View previous topic :: View next topic  
Author Message
Jeff Swanberg
Guest





PostPosted: Sat Apr 24, 2004 3:25 pm    Post subject: One and only one record checked in table Reply with quote



I have a Pdx table with a Logical field. On the data entry form for this
table, I have a DBCheckBox related to this field. I need to write code so
that, when the user checks the box to "True" that whatever other record
currently has that field set to "True" gets switched to "False" so that only
one record has the checkbox checked at any time.

Everytime I try to do this, I get stuck in an endless loop.

Ideas??

Jeff


Back to top
Woody (TMW)
Guest





PostPosted: Sat Apr 24, 2004 5:32 pm    Post subject: Re: One and only one record checked in table Reply with quote



"Jeff Swanberg" <jswanberg (AT) swanbergcomputing (DOT) com> wrote

Quote:
I have a Pdx table with a Logical field. On the data entry form for this
table, I have a DBCheckBox related to this field. I need to write code so
that, when the user checks the box to "True" that whatever other record
currently has that field set to "True" gets switched to "False" so that
only
one record has the checkbox checked at any time.

Everytime I try to do this, I get stuck in an endless loop.

Use a separate query to set the field to false in the other records. Also,
you can use a normal check box and set it according to the current record.
That way, you could handle all the code yourself.

HTH

--
Woody (TMW)
Freeware Page: http://users.eonet.net/woodytmw

All computers wait at the same speed.



Back to top
Bill Todd (TeamB)
Guest





PostPosted: Sat Apr 24, 2004 7:35 pm    Post subject: Re: One and only one record checked in table Reply with quote



Assuming that there are a large number of rows in the table, I would
do the following.

Index the boolean field.
Use a second TTable connected to the same database table.
Use FindKey on the second TTable to locate the existing checked row.
Uncheck the existing row.


--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.