Question

Here is an outline of the table I am working with:

Quote - a unique, not null number
Revision - text, a single character (not unique, allows null)

The combination of Quote and Revision must be unique, even when Revision is null. So for instance, the table allows both (123,A) and (123,B) but should not allow (123,A) or (123,null) to be stored multiple times.

At present I have a 'unique' index on Quote and Revision (set in the Indexes window), which gives the required behaviour except for when Revision is null. In the index I've got 'ignore nulls' set to No, but this doesn't solve it.

From trying to find a solution I'm guessing that I need to use some kind of conditional index or constraint, but I haven't managed to get it working so far (this is the first time I've needed to tackle a problem of this kind so don't have much experience).

Any help to get this working would be much appreciated!

Was it helpful?

Solution

For Access 2003 I think the closest you'll get will be to use empty strings instead of Null values. That is, you would convert existing Nulls to empty strings...

UPDATE Quotes SET Revision="" WHERE Revision IS NULL

...then open the table in Design View and set the following properties for the [Revision] field:

Default Value: ""  
Required: Yes
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top