Re: Parsing (Contencate?) 2 fields into 1



=?Utf-8?B?RW5nZWxz?= <Engels@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
news:E4BE2EDC-5C66-48B1-907B-25BA06F6D9BB@xxxxxxxxxxxxx:

I need some code that will take the data from these two fields and
combine them to make Course ID before i save the record since i will
need the PK to be able to do this.

No you don't: really bad idea. Can I suggest that your tables look
something like

CourseTypes (
CourseType Text(3) PRIMARY KEY,
FullName Text(32),
Duration Integer,
TutoredBy Text(5),
etc
)

TrainingCourses (
StartDate DateTime,
CourseType Text(3) FOREIGN KEY REFERENCES CourseTypes,
PaidUp Currency,
etc
CONSTRAINT pk PRIMARY KEY (StartDate, CourseType)
)

(PS: you can mess about with spaces and brackets if you like, but for
legibility I have used only legal characters in table and field names)

You really need to keep the CourseType as a separate field in the
TrainingCourses table, because otherwise you wont be able to enforce the
relationship with the CourseTypes table. There is no problem with making
the pair of fields into the Primary Key: just ctrl-click the rows in the
table design and then click the yellow key toolbar button.

Hope that helps


Tim F

.