3265 Item not found in this collection.

  • Thread starter Thread starter Stapes
  • Start date Start date
S

Stapes

Hi

I am adding a new record here, then trying to pick up the autonumber
key field for the record just written. I get 3265 Item not found in
this collection.

With rsCust
'#### add each item into a new record
.AddNew
.Fields("Co") = rsComp.Fields("Company")
.Fields("Add1") = rsComp.Fields("Address1")
.Fields("Add2") = rsComp.Fields("Address2")
.Fields("Add3") = ""
.Fields("Town") = rsComp.Fields("Town")
.Fields("Cnty") = rsComp.Fields("County")
.Fields("Pocd") = rsComp.Fields("Post Code")
.Fields("Country") = rsComp.Fields("Country")
.Fields("DT_Audit") = Date
.Update
.Close
End With
MsgBox "Customer record created. Key = " &
rsComp.Fields("PK_Comp")

Any ideas?

Stapes
 
Not sure, but at a glance i would say it should be:
MsgBox "Customer record created. Key = " &
rsCust.Fields("PK_Comp")

HTH
 
Not sure, but at a glance i would say it should be:
MsgBox "Customer record created. Key = " &
rsCust.Fields("PK_Comp")

I suspect that that line is probably causing the error as well, but
rsCust would cause an error because rsCust is already closed.

If that line is causing the error then the field named "PK_Comp" does
not exist in the recordset for rsComp.

Cheers,
Jason Lepack
 
Hi

No - it is not that. PK_Comp is part of the record just added - an
autonumber field which should self increment.

Stapes
 
Not sure, but at a glance i would say it should be:
MsgBox "Customer record created. Key = " &
rsCust.Fields("PK_Comp")

HTH

Hi

No - it is not that. PK_Comp is part of the record just added - an
autonumber field which should self increment.


Stapes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top