Solved

How to solve runtime error '2147352567(80020009)'

Posted on 2011-03-25
11
2,545 Views
Last Modified: 2013-11-27
I get this error when I try to change a control on a form and the control is a primary key in the underlying table.
0
Comment
Question by:SowleMan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 75
ID: 35217743
If the PK is an Access AutoNumber (?), then it cannot be changed.

mx
0
 

Author Comment

by:SowleMan
ID: 35219055
Thanks, DatabaseMX.  

I really don't want to change the key.  I want to replace the key with another, valid PK.  For example, I want to modify a transaction record so it points to The Home Depot, instead of  Lowes.

Sowleman
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35222221
Then something seems awry in your design...

For example: If you are a shipper and you want to change the ship destination from Home Depot, to Lowes.

The you have a "Stores" table:

tblStores
StoreID (Primary Key)
StoreName
...ect

..Then you have a shipments table

tblShipments
ShipmentID (Primary Key)
StoreID (Foreign Key)
ShipmentDate
...etc

These two tables are linked in the relationships window on "StoreID", and Referential Integrity is enforced.

In this case, it is quite easy to change the StoreID in the shipments table to another StoreID, without issue.

So you will have to explain to us the design and relationships between your tables.
Also provide us with the details of how and where, exactly, you are trying to change the ID.


JeffCoachman

0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 75
ID: 35222388
Guess I'm not quite following.  Maybe Jeff has explained what you are after?

mx
0
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 35222504
Changing a value in a key field might result in a violation of normalization.  We need more information on what you are trying to do, in terms of tables, fields and relationships.
0
 

Author Comment

by:SowleMan
ID: 35222626
Thanks - I really appreciate your interest in my problem.
Jeff described my situation well.  I have a tblStores with fields StoreID (primaryKey, auto-number) and StoreName.  tblShipments contains a foreign key (also called StoreID) in order to retrieve StoreName via an ACCESS relationship.  I expect the relationship to maintain referential integrity.

In my system, I use a query to retrieve fields  from tblStores and tblShipments, and that query is the recordsource for my form. I sometimes detect an improper StoreName. Example: a tblShipments record shows Home Depot and I want to change it to Lowes.  Using VBA, I retrieve from tblStores the Lowes StoreID and I want to assign the Lowes StoreID to tblShipments.StoreID.  ACCESS replies with runtime error  '-2147352567(80020009)', "To make changes to this field, you must first save the record".

The actual VBA that causes the error: me.StoreID = longStoreID.  I am trying to make this change by assigning the correct StoreID to the foreign key (displayed but not enabled) in the form.

I am learning this stuff as a retirement hobby, so my education is weak in many areas.  30 years ago I programmed in COBOL.

Steve
0
 

Author Comment

by:SowleMan
ID: 35222674
Helen/ MX/ Jeff -  Could it be that I have to delete the inaccurate record and then add a new, correct record?  If am comfortable with DAO, but is there a way to manipulate the data in the underlying query without messing up the flow of the form?

Steve
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35223805
Unless you also assigned StoreID in the shipments table as Primary key, I can't see what the problem might be...

You did not say by what method you are assigning longStoreID, but in a global sense you may want to use a combobox.

Here is a very simple sample, there are no problems with changing the store.

JeffCoachman


db344.mdb
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35223815
ooops, ...here is the sample
db344.mdb
0
 

Accepted Solution

by:
SowleMan earned 0 total points
ID: 35363794
DatabaseMX -

If I cannot change a field that is a Primary Key, then the solution is to delete the child row and then re-add a replacement child row with new info (allowing ACCES to provide a new PK) ?

Thanks.
0
 

Author Closing Comment

by:SowleMan
ID: 35446447
I did not get a workable answer.  I want to close it so I casn move on
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question