Forum Discussion

MV77511's avatar
MV77511
Copper Contributor
May 06, 2022

Create Table statement not working in Access

CREATE TABLE Patient
(
taxCode VARCHAR(16) NOT NULL PRIMARY KEY,
name VARCHAR(32) NOT NULL,
surname VARCHAR(64) NOT NULL,
username VARCHAR(16) NOT NULL UNIQUE,
password VARCHAR(16) NOT NULL,
email VARCHAR(32) NOT NULL UNIQUE,
address VARCHAR(64) NOT NULL,
gender SHORT NOT NULL,
birthDate DATETIME NOT NULL,
adminCode VARCHAR(16) NOT NULL,
CONSTRAINT FKPatientToAdmin FOREIGN KEY (adminCode) REFERENCES Admin ON UPDATE CASCADE ON DELETE SET NULL
)

 

This statement looks pretty ok to me, given I based it on access' own documentation. Still, it won't work, giving me a CONSTRAINT error and highlighting UPDATE while giving it.
Is someone able to tell me why Access rejects this?

This is my Admin table I already created:
CREATE TABLE Admin 
( 
adminCode VARCHAR(16) NOT NULL PRIMARY KEY, 
username VARCHAR(16) NOT NULL UNIQUE, 
password VARCHAR(16) NOT NULL, 
reference VARCHAR(16) NOT NULL UNIQUE, 
email VARCHAR(32) NOT NULL UNIQUE 
) 

Resources