Working with form records

Your ProductT does not have an ID of 0

To rectify the problem you need to add a record to the ProductT table with the Description of "Hourly Billing" with an ID of 7

Then you need to Update OrderdetailsT and change all of the 0 values to 7

Why not just insert a row into ProductT with a ProductID value of 0, and a Description value of 'Hourly Billing'? That way there's no need to update OrderDetailT, and the relationship can be enforced. The DefaultValue property of ProductID in OrderDetailT can be left as 0 or made Null as the OP considers most appropriate.

PS: I'd also recommend changing the name of the Description column to ProductDescription or similar. The former is a property name, and as such can be considered a reserved key word inappropriate for use as an object name.
 
Why not just insert a row into ProductT with a ProductID value of 0, and a Description value of 'Hourly Billing'? That way there's no need to update OrderDetailT, and the relationship can be enforced. The DefaultValue property of ProductID in OrderDetailT can be left as 0 or made Null as the OP considers most appropriate.

PS: I'd also recommend changing the name of the Description column to ProductDescription or similar. The former is a property name, and as such can be considered a reserved key word inappropriate for use as an object name.
Hi Ken
Please ignore my ignorance but I was always under the impression that if you have a ProductID as the PK Long Integer Autonumber you would not be able to have a 0 value
 
I was always under the impression that if you have a ProductID as the PK Long Integer Autonumber you would not be able to have a 0 value
You can - it just isn't generated automatically (except perhaps you might get one if you set the field to random rather than increment) . I sometimes use a 0 PK record to hold default or message type values. However you do need to insert the record as the autonumber field cannot be edited. I also use -1, -2, etc for similar reasons.

Useful in comboboxes where you want to set a message such as 'required' (Assuming the default for the combo is 0) rather than using a union query for the rowsource.
 
You can - it just isn't generated automatically (except perhaps you might get one if you set the field to random rather than increment) . I sometimes use a 0 PK record to hold default or message type values. However you do need to insert the record as the autonumber field cannot be edited. I also use -1, -2, etc for similar reasons.

Useful in comboboxes where you want to set a message such as 'required' (Assuming the default for the combo is 0) rather than using a union query for the rowsource.
Well you learn something everyday.
 
I was always under the impression that if you have a ProductID as the PK Long Integer Autonumber you would not be able to have a 0 value

You're not alone, many people make the same assumption in my experience. An autonumber is really a mechanism rather than a data type. It's a long integer data type with the added functionality of generating a distinct number when a row is inserted. An INSERT INTO statement can still be executed to insert any currently unused literal value, however. I generally use a zero as a default value, though it's only for superficial neatness really. It has no semantic significance.
 

Users who are viewing this thread

Back
Top Bottom