I have a basic entry form that after pressing F9 to save performs the following code (just a portion):
With rst1
.AddNew
.Fields(0) = x 'Permno
.Fields(1) = Me!LAST 'Last Name
.Fields(2) = Me!FIRST 'First Name
.Fields(3) = Me!ADD1 'Street Address 1
.Fields(4) = Me!ADD2 'Street Address 2
.Fields(5) = Me!CITY 'City
.Fields(6) = Me!ST 'Last Name
.Fields(7) = Me!ZIP 'First Name
.Fields(12) = Me!PHONE 'Phone number
.Fields(13) = Me!LICENSE 'Drivers License #
.Fields(14) = Me!SSN 'Social Security #
.Fields(16) = Me!COUNTY 'County
.Fields(30) = -1 'Set update to true
.Fields(31) = Date
.UPDATE
End With
End sub
After the the end sub I get the following error:
Index or Primary Key cannot contain a null value
The key is field(0) 'Permno
the value x is a valid number and the record acutally saves with the key and all other values intact, but this error dialog comes up. I assume I need another command to clear the form and get ready for a new record and thought maybe this was part of the problem. Any Idea's????
With rst1
.AddNew
.Fields(0) = x 'Permno
.Fields(1) = Me!LAST 'Last Name
.Fields(2) = Me!FIRST 'First Name
.Fields(3) = Me!ADD1 'Street Address 1
.Fields(4) = Me!ADD2 'Street Address 2
.Fields(5) = Me!CITY 'City
.Fields(6) = Me!ST 'Last Name
.Fields(7) = Me!ZIP 'First Name
.Fields(12) = Me!PHONE 'Phone number
.Fields(13) = Me!LICENSE 'Drivers License #
.Fields(14) = Me!SSN 'Social Security #
.Fields(16) = Me!COUNTY 'County
.Fields(30) = -1 'Set update to true
.Fields(31) = Date
.UPDATE
End With
End sub
After the the end sub I get the following error:
Index or Primary Key cannot contain a null value
The key is field(0) 'Permno
the value x is a valid number and the record acutally saves with the key and all other values intact, but this error dialog comes up. I assume I need another command to clear the form and get ready for a new record and thought maybe this was part of the problem. Any Idea's????