HELP: Run-time error 3219
I am trying to insert a single, 1 column record into a table using ADO. Note that all variables have been Dim'd. Here is the code, with line #'s:
1. SqlInsertStr = "Insert into tblDummyS3ID (DummyS3ID) Values (NewMaxS3ID);"
2. recset.Open "tblDummyS3ID", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
3. With recset
4. .Fields("DummyS3ID") = NewMaxNumber
5. .AddNew
6. .Update
7. End With
8. recset.Close
9. Set recset = Nothing
Currently, when line 6 executes, I get the following error:
"Index or primary key cannot contain a Null value."
The table has only 1 column, which is the PK. The variable newMaxNumber was set earlier in the code and the correct value to insert is confirmed. After the run-time error occurs, I stop execution of the code, go back to design view on the form, then look at the table. Each insert should add a new row, however, there is only 1 row, and that value is being updated. This is not necessarily bad because the end result is the same. However, this is not what I expect. I expect a new row to be added, not an update to the row which already exists.
Can anyone explain this behavior to me and how to resolve the 3219?
TIA,
Rich

