P
placek
Hi there,
I'm updating a table of mine and Access is creating a
phantom record with random values in the fields. My table
has 4 fields: lngBorrowerNumberCnt,
lngAcquisitionNumberCnt, dtmDateReserved and
dtmDateBorrowed. The table is called tblLoanRelation.
The code is:
Set recLoanRelation = dbshigham.OpenRecordset
("tblLoanRelation", dbOpenDynaset)
recLoanRelation.AddNew
recLoanRelation("lngBorrowerNumberCnt") = lngBorrowerNumber
recLoanRelation("lngAcquisitionNumberCnt") =
lngAcquisitionNumber
recLoanRelation("dtmDateBorrowed") = Date
recLoanRelation.Update
Although Access creates a new record with the specified
values, it created a second row, although i did not
specify this. It then proceeded to insert a random number
in lngAcquisitionNumberCnt, while leaving the remaining
fields null. This then generated an error as the composite
primary key fields (lngBorrowerNumberCnt and
lngAcquisitionNumberCnt) are specified as not null in the
design.
Does anyone have a clue why this is happening? I read
somewhere that when using update and addnew methods, the
underlying table must contain a unique index. Does a
composite primary key count as a unique index?
Thanks in advance
Martin
I'm updating a table of mine and Access is creating a
phantom record with random values in the fields. My table
has 4 fields: lngBorrowerNumberCnt,
lngAcquisitionNumberCnt, dtmDateReserved and
dtmDateBorrowed. The table is called tblLoanRelation.
The code is:
Set recLoanRelation = dbshigham.OpenRecordset
("tblLoanRelation", dbOpenDynaset)
recLoanRelation.AddNew
recLoanRelation("lngBorrowerNumberCnt") = lngBorrowerNumber
recLoanRelation("lngAcquisitionNumberCnt") =
lngAcquisitionNumber
recLoanRelation("dtmDateBorrowed") = Date
recLoanRelation.Update
Although Access creates a new record with the specified
values, it created a second row, although i did not
specify this. It then proceeded to insert a random number
in lngAcquisitionNumberCnt, while leaving the remaining
fields null. This then generated an error as the composite
primary key fields (lngBorrowerNumberCnt and
lngAcquisitionNumberCnt) are specified as not null in the
design.
Does anyone have a clue why this is happening? I read
somewhere that when using update and addnew methods, the
underlying table must contain a unique index. Does a
composite primary key count as a unique index?
Thanks in advance
Martin