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 » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

A semi-unique index?



 
 
Thread Tools Display Modes
  #11  
Old December 6th, 2007, 06:10 PM posted to microsoft.public.access.tablesdbdesign
Dale Fye
external usenet poster
 
Posts: 2,651
Default A semi-unique index?

This is the approach I would take as well. But rather than "spin through the
users existing records", I think I would just write an update query that sets
all of the other Preferred values for that user to false.

HTH
Dale

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



"Matthew" wrote:

Ah, so it'll be done with code in the front end, not at the table level.

Thanks for your help!!!

Matthew

"Dennis" wrote in message
...
Using something like Address as a primary key is not doable. Simply add a
Yes/No field to the table called "PREFERRED" (or whatever you want). If
they
check it, it's a preferred address. Then, when they go to add another
address, if they check Preferred, in the BEFORE UPDATE event, spin though
the
user's existing records looking for the checkbox set in any other one (You
can use DLookup for that). If a YES is found for any other address, popup
a
MSGBOX with the error and CANCEL the Update/add.

"Matthew" wrote:

I feel like there's a simple answer which eludes me.

I'm trying to make it so that a person can only have one preferred
address.

tblPeople
*PersonID
etc.

tblAddresses
*AddressID
PersonID
StreetAddress..
PreferredAddress (y/n)

I've tried creating an index in tblAddresses using the two fields
PersonID
and PreferredAddress, and setting it to Unique and Ignore Nulls.

That makes it so that no person can have two addresses marked as
preferred,
but they also cannot have two addresses NOT marked as preferred.

I want a person to be able to have as many not-preferred addresses as
they
want, but only one of them can be designated as preferred.

How can I do this?

Many thanks in advance!!

Matthew






  #12  
Old December 6th, 2007, 06:32 PM posted to microsoft.public.access.tablesdbdesign
Dennis
external usenet poster
 
Posts: 1,222
Default A semi-unique index?

Except that it would be nice to get a popup box that says, "There is already
a preferred addess defind; would you like to use the new one as preferred?"
(YES/NO)

That lets the user decide what to do. When the computer does "stuff"
automatically, you never really know what's going on under the sheets.

JMHO - YMMV

"Dale Fye" wrote:

This is the approach I would take as well. But rather than "spin through the
users existing records", I think I would just write an update query that sets
all of the other Preferred values for that user to false.

HTH
Dale

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



"Matthew" wrote:

Ah, so it'll be done with code in the front end, not at the table level.

Thanks for your help!!!

Matthew

"Dennis" wrote in message
...
Using something like Address as a primary key is not doable. Simply add a
Yes/No field to the table called "PREFERRED" (or whatever you want). If
they
check it, it's a preferred address. Then, when they go to add another
address, if they check Preferred, in the BEFORE UPDATE event, spin though
the
user's existing records looking for the checkbox set in any other one (You
can use DLookup for that). If a YES is found for any other address, popup
a
MSGBOX with the error and CANCEL the Update/add.

"Matthew" wrote:

I feel like there's a simple answer which eludes me.

I'm trying to make it so that a person can only have one preferred
address.

tblPeople
*PersonID
etc.

tblAddresses
*AddressID
PersonID
StreetAddress..
PreferredAddress (y/n)

I've tried creating an index in tblAddresses using the two fields
PersonID
and PreferredAddress, and setting it to Unique and Ignore Nulls.

That makes it so that no person can have two addresses marked as
preferred,
but they also cannot have two addresses NOT marked as preferred.

I want a person to be able to have as many not-preferred addresses as
they
want, but only one of them can be designated as preferred.

How can I do this?

Many thanks in advance!!

Matthew






  #13  
Old December 6th, 2007, 08:00 PM posted to microsoft.public.access.tablesdbdesign
Dale Fye
external usenet poster
 
Posts: 2,651
Default A semi-unique index?

Yeah, I thought about it as well, but then I figured, if the user selects
"make this my preferred addres", he probably knows what he's talking about.

Dale
--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



"Dennis" wrote:

Except that it would be nice to get a popup box that says, "There is already
a preferred addess defind; would you like to use the new one as preferred?"
(YES/NO)

That lets the user decide what to do. When the computer does "stuff"
automatically, you never really know what's going on under the sheets.

JMHO - YMMV

"Dale Fye" wrote:

This is the approach I would take as well. But rather than "spin through the
users existing records", I think I would just write an update query that sets
all of the other Preferred values for that user to false.

HTH
Dale

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



"Matthew" wrote:

Ah, so it'll be done with code in the front end, not at the table level.

Thanks for your help!!!

Matthew

"Dennis" wrote in message
...
Using something like Address as a primary key is not doable. Simply add a
Yes/No field to the table called "PREFERRED" (or whatever you want). If
they
check it, it's a preferred address. Then, when they go to add another
address, if they check Preferred, in the BEFORE UPDATE event, spin though
the
user's existing records looking for the checkbox set in any other one (You
can use DLookup for that). If a YES is found for any other address, popup
a
MSGBOX with the error and CANCEL the Update/add.

"Matthew" wrote:

I feel like there's a simple answer which eludes me.

I'm trying to make it so that a person can only have one preferred
address.

tblPeople
*PersonID
etc.

tblAddresses
*AddressID
PersonID
StreetAddress..
PreferredAddress (y/n)

I've tried creating an index in tblAddresses using the two fields
PersonID
and PreferredAddress, and setting it to Unique and Ignore Nulls.

That makes it so that no person can have two addresses marked as
preferred,
but they also cannot have two addresses NOT marked as preferred.

I want a person to be able to have as many not-preferred addresses as
they
want, but only one of them can be designated as preferred.

How can I do this?

Many thanks in advance!!

Matthew






 




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 04:45 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.