My table is on a SQL Server as defined below. When the Unique Constraint is added to the table, the Access data entry form displays #Deleted in all fields of a record that was just entered. I can get around the situation by requerying and forcing a new record. There are usually only 1 - 3 records per user.
Requery
DoCmd.GoToRecord , , acNewRec
Why does adding the Unique Constraint interfere with the Access form? The form works fine without the unique constraint.
CREATE TABLE [dbo].[tbl_INV_cust_inv_us_temp] (
[inv_loc] [char](3) NOT NULL,
[inv_no] [char](7) NOT NULL,
[std_GUID] [uniqueidentifier] NOT NULL,
[std_NewRecordInd] [bit] NOT NULL,
[std_Create_TS] [datetime] NOT NULL,
[std_Create_ID] [varchar](50) NOT NULL
);
GO
ALTER TABLE [dbo].[tbl_INV_cust_inv_us_temp]
ADD CONSTRAINT [DF_tbl_INV_cust_inv_us_temp_std_GUID]
DEFAULT (newid()) FOR [std_GUID];
GO
ALTER TABLE [dbo].[tbl_INV_cust_inv_us_temp]
ADD CONSTRAINT [DF_tbl_INV_cust_inv_us_temp_std_NewRecordInd]
DEFAULT (1) FOR [std_NewRecordInd];
GO
ALTER TABLE [dbo].[tbl_INV_cust_inv_us_temp]
ADD CONSTRAINT [DF_tbl_INV_cust_inv_us_temp_std_Create_TS]
DEFAULT (getdate()) FOR [std_Create_TS];
GO
ALTER TABLE [dbo].[tbl_INV_cust_inv_us_temp]
ADD CONSTRAINT [DF_tbl_INV_cust_inv_us_temp_std_Create_ID]
DEFAULT (right(suser_sname(),(len(suser_sname()) - 9))) FOR [std_Create_ID];
GO
ALTER TABLE [dbo].[tbl_INV_cust_inv_us_temp]
ADD CONSTRAINT [IX_tbl_INV_cust_inv_us_temp]
UNIQUE NONCLUSTERED (
[inv_loc] ASC,
[inv_no] ASC,
[std_Create_ID] ASC)
WITH (
PAD_INDEX = OFF,
STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON )
ON [PRIMARY];
GO