Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem after using the .Update command 1

Status
Not open for further replies.

emumaster

Programmer
Aug 30, 2001
31
US
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????
 

Is the form bound an any way to the table? Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
Yes the recordsource for the form is bound to the table that the fields on the form belong to.
 

If the table is bound to the form, why are you updating the table in code? A record is added in code and then when the user moves from the form, Access attempts to add another record but this one lacks the primary key and generates the error. Either remove the code that adds the record or unbind the form from the table. Terry L. Broadbent
Life would be easier if I had the source code. -Anonymous
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top