Discussion Locked

VB6/Access97 - RecordSet.Update

0 helpful
11 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am receiving a runtime error (3314) when saving a new record to an Access 97 DB: "The field "Titles.ISBN" cant contain a null value because the required property for this field is set to true".
The ISBN field is the PK of the Titles table and a FK in the AuthorISBN table.
The relationship between the tables is 1(Titles) to many(AuthorISBN).
Both recordsets have been .AddNew and the error occurs at the .Update for the recordsets, when i select cmdSave.

11 replies

by donq

It sounds like your structure is OK and the Table's PK value isn't being inserted into the AuthorISBN field. If you are doing this by code make sure you set your recordset to .AddNew as part of your iteration.

by tranman

This may be a dumb question, but are you putting data in the primary key field in the recordset before you try to save the record?

Example:
recordsetname.fields("ISBN") = txtName.text

If you try to add a blank row, or one without the primary key, it will not work.

by miss kitty

Why not make an update query in Access97? When you update in your vb application, run the Access update query and everything should be fine.

by seagull data services

It's hard to know what's going wrong without seeing your code but the error seems to be that you are not updating the ISBN field before saving the record.
Another thing to note is that you should save the one side of a relationship before attempting to write records to the many side.
If none of the tips here help, try posting your code.

by camcc591

In the table definition properties for the field titles.isbn is the property "Allow Zero Length" set to no? Should be set to yes to allow a null value.

If you do not want a null value stored, try the using Nz function.

This discussion is closed to new replies.