![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
First a few words on dutch names. In dutch a surname can consist of two parts: a (optional) prfix plus a surname. So "Piet van der Graaf" is a typical dutch name. In databases dutch surnames are stored in two fields. In my databes I have 4 fields which I want to be a ubique index: - First name (Piet) - Prefix to surname (van der) - Surname (Graaf) - Date of birth I created a index (unique, not primary, ignore nulls). If all fields are not null, everything works as hoped. Levaing the prefix null gives unwanted results. If I enter 2 records (Jan,null , Punt, 01/01/1960) Access aacepts both. What can I do to create a unique index with an optional field? TIA. |
#3
| |||
| |||
|
|
First a few words on dutch names. In dutch a surname can consist of two parts: a (optional) prfix plus a surname. So "Piet van der Graaf" is a typical dutch name. In databases dutch surnames are stored in two fields. In my databes I have 4 fields which I want to be a ubique index: - First name (Piet) - Prefix to surname (van der) - Surname (Graaf) - Date of birth I created a index (unique, not primary, ignore nulls). If all fields are not null, everything works as hoped. Levaing the prefix null gives unwanted results. If I enter 2 records (Jan,null , Punt, 01/01/1960) Access aacepts both. What can I do to create a unique index with an optional field? TIA. -- Groeten, Peter http://access.xps350.com --- news://freenews.netfront.net/ - complaints: news (AT) netfront (DOT) net --- |
#4
| |||
| |||
|
|
XPS35 <xps... (AT) gmail (DOT) com> wrote innews:i4ukea$1ibd$1 (AT) adenine (DOT) netfront.net: First a few words on dutch names. In dutch a surname can consist of two parts: a (optional) prfix plus a surname. So "Piet van der Graaf" is a typical dutch name. In databases dutch surnames are stored in two fields. In my databes I have 4 fields which I want to be a ubique index: - First name (Piet) - Prefix to surname (van der) - Surname (Graaf) - Date of birth I created a index (unique, not primary, ignore nulls). If all fields are not null, everything works as hoped. Levaing the prefix null gives unwanted results. If I enter 2 records (Jan,null , Punt, 01/01/1960) Access aacepts both. What can I do to create a unique index with an optional field? TIA. I would set the prefix field to 1) default value = "" (the empty string). 2) Required = yes 3) allow Zero length = yes |
#5
| |||
| |||
|
|
The reason it's not working is that Null is never equal to anything, not even another Null value. However, realistically even with the addition of birthdate in there, there's no guarantee it's going to be unique, so why even try? -- Doug Steele, Microsoft Access MVPhttp://www.AccessMVP.com/djsteele Co-author: "Access 2010 Solutions", published by Wiley (no e-mails, please!) "XPS35" <xps... (AT) gmail (DOT) com> wrote in message news:i4ukea$1ibd$1 (AT) adenine (DOT) netfront.net... First a few words on dutch names. In dutch a surname can consist of two parts: a (optional) prfix plus a surname. So "Piet van der Graaf" is a typical dutch name. In databases dutch surnames are stored in two fields. In my databes I have 4 fields which I want to be a ubique index: - First name (Piet) - Prefix to surname (van der) - Surname (Graaf) - Date of birth I created a index (unique, not primary, ignore nulls). If all fields are not null, everything works as hoped. Levaing the prefix null gives unwanted results. If I enter 2 records (Jan,null , Punt, 01/01/1960) Access aacepts both. What can I do to create a unique index with an optional field? TIA. -- Groeten, Peter http://access.xps350.com --- news://freenews.netfront.net/ - complaints: n... (AT) netfront (DOT) net --- |
#6
| |||
| |||
|
|
On 23 aug, 23:24, "Douglas J. Steele" NOSPAM_djsteele (AT) NOSPAM_gmail (DOT) com> wrote: The reason it's not working is that Null is never equal to anything, not even another Null value. However, realistically even with the addition of birthdate in there, there's no guarantee it's going to be unique, so why even try? -- Doug Steele, Microsoft Access MVPhttp://www.AccessMVP.com/djsteele Co-author: "Access 2010 Solutions", published by Wiley (no e-mails, please!) "XPS35" <xps... (AT) gmail (DOT) com> wrote in message news:i4ukea$1ibd$1 (AT) adenine (DOT) netfront.net... First a few words on dutch names. In dutch a surname can consist of two parts: a (optional) prfix plus a surname. So "Piet van der Graaf" is a typical dutch name. In databases dutch surnames are stored in two fields. In my databes I have 4 fields which I want to be a ubique index: - First name (Piet) - Prefix to surname (van der) - Surname (Graaf) - Date of birth I created a index (unique, not primary, ignore nulls). If all fields are not null, everything works as hoped. Levaing the prefix null gives unwanted results. If I enter 2 records (Jan,null , Punt, 01/01/1960) Access aacepts both. What can I do to create a unique index with an optional field? TIA. -- Groeten, Peter http://access.xps350.com --- news://freenews.netfront.net/ - complaints: n... (AT) netfront (DOT) net --- Douglas, Thanks for your reply. I now understand why it did not work. Your are right about the fields not being unique, but that wasn't my issue. |
#7
| |||
| |||
|
|
So, anyone, how can you create a primary key (or simulate it without too much work) where one of the fields may be null or empty or have no value? I have the same issue, a database table where the most natural and useful key has a field that might be null. |
#8
| |||
| |||
|
|
On 23 aug, 23:24, "Douglas J. Steele" NOSPAM_djsteele (AT) NOSPAM_gmail (DOT) com> wrote: The reason it's not working is that Null is never equal to anything, not even another Null value. However, realistically even with the addition of birthdate in there, there's no guarantee it's going to be unique, so why even try? -- Doug Steele, Microsoft Access MVPhttp://www.AccessMVP.com/djsteele Co-author: "Access 2010 Solutions", published by Wiley (no e-mails, please!) "XPS35" <xps... (AT) gmail (DOT) com> wrote in message news:i4ukea$1ibd$1 (AT) adenine (DOT) netfront.net... First a few words on dutch names. In dutch a surname can consist of two parts: a (optional) prfix plus a surname. So "Piet van der Graaf" is a typical dutch name. In databases dutch surnames are stored in two fields. In my databes I have 4 fields which I want to be a ubique index: - First name (Piet) - Prefix to surname (van der) - Surname (Graaf) - Date of birth I created a index (unique, not primary, ignore nulls). If all fields are not null, everything works as hoped. Levaing the prefix null gives unwanted results. If I enter 2 records (Jan,null , Punt, 01/01/1960) Access aacepts both. What can I do to create a unique index with an optional field? TIA. -- Groeten, Peter http://access.xps350.com --- news://freenews.netfront.net/ - complaints: n... (AT) netfront (DOT) net --- Douglas, Thanks for your reply. I now understand why it did not work. Your are right about the fields not being unique, but that wasn't my issue. So, anyone, how can you create a primary key (or simulate it without too much work) where one of the fields may be null or empty or have no value? I have the same issue, a database table where the most natural and useful key has a field that might be null. |
#9
| |||
| |||
|
|
First a few words on dutch names. In dutch a surname can consist of two parts: a (optional) prfix plus a surname. So "Piet van der Graaf" is a typical dutch name. In databases dutch surnames are stored in two fields. In my databes I have 4 fields which I want to be a ubique index: - First name (Piet) - Prefix to surname (van der) - Surname (Graaf) - Date of birth I created a index (unique, not primary, ignore nulls). If all fields are not null, everything works as hoped. Levaing the prefix null gives unwanted results. If I enter 2 records (Jan,null , Punt, 01/01/1960) Access aacepts both. What can I do to create a unique index with an optional field? TIA. -- Groeten, Peterhttp://access.xps350.com --- news://freenews.netfront.net/ - complaints: n... (AT) netfront (DOT) net --- |
#10
| |||
| |||
|
|
First a few words on dutch names. In dutch a surname can consist of two parts: a (optional) prfix plus a surname. So "Piet van der Graaf" is a typical dutch name. In databases dutch surnames are stored in two fields. In my databes I have 4 fields which I want to be a ubique index: - First name (Piet) - Prefix to surname (van der) - Surname (Graaf) - Date of birth I created a index (unique, not primary, ignore nulls). If all fields are not null, everything works as hoped. Levaing the prefix null gives unwanted results. If I enter 2 records (Jan,null , Punt, 01/01/1960) Access aacepts both. What can I do to create a unique index with an optional field? TIA. -- Groeten, Peterhttp://access.xps350.com --- news://freenews.netfront.net/ - complaints: n... (AT) netfront (DOT) net --- Many times I have a field in my table generally called 'UKey' and when I'm saving a record I create a unique key with this instead of trying to create a primary key using other table fields MyRec!UKey = Format(Date, "mmddyyyy") & Format(Time(), "hhnnss") bobh. |
![]() |
| Thread Tools | |
| Display Modes | |
| |