Re: Primary Key Unexpectedly Gone from Table

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks for the reply, Allen.

I don't understand how the entered data could violate the index when the PK
is an AutoNumber field. The [id] field is not visible on the form and
therefore not a value that is entered by the user.

If the db is split, where does the Function CreateIndexesDAO() in your
example reside?


"Allen Browne" wrote:

See the last symptom of corruption in this article:
http://allenbrowne.com/ser-47.html#LostKeyRelation

It is actually possible to programmatically create an index on a linked
table, if you OpenDatabase on the back end so you are operating on that file
instead of CurrentDb. You can then CreateIndex on the TableDef, CreateField
and append the fields to the index, set its Primary property ot True, and
append this new index to the tables Indexes collections.

For an example, see:
http://allenbrowne.com/func-DAO.html#CreateIndexesDAO

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Simon" <Simon@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5C722746-B861-465E-8F55-328C336F5E39@xxxxxxxxxxxxxxxx
Can you tell me if you have ever heard of this happening and why?

The first indication that 'something' is wrong with the db is that users
are
no longer able to enter data into forms whose RecordSource contains this
table (Person) and others. If I look at the Person table, I can see that
there is no longer a Primary Key set. I can re-set the Primary Key to the
[id] field. A month later, users cannot enter into the forms where the
Person table is part of the RecordSource, and I find that the Primary Key
is
missing from the Person table again. What is causing the PK to disappear??
As the db is split, I cannot run any data definition code to set the PK on
linked tables! (right?)

This is a database that has been in production for several years. The db
is
split and both front end and back end are .MDEs. There are absolutely no
data
definition statement in the code that 'could' have eliminated the Primary
Key
for the table(because the tables are linked) DB is Access 2000.

Any ideas on what is happening and why??
I really appreciate any input you may have!
Thanks
Simon


.



Relevant Pages

  • Re: can we set a primary key on a form in access database if yes how?
    ... I'm not sure what you're question means, to be honest. ... you have to consider what you do when the user types in a value ... to see if the resulting primary key already exists. ... entered data that won't create a collision, ...
    (microsoft.public.access.forms)
  • Re: Primary Key Unexpectedly Gone from Table
    ... Tips for Access users - http://allenbrowne.com/tips.html ... there is no longer a Primary Key set. ... Person table is part of the RecordSource, and I find that the Primary Key is ... I cannot run any data definition code to set the PK on ...
    (microsoft.public.access.tablesdbdesign)
  • Re: How to Add Field with Index
    ... Set fld = idx.CreateField("ShipCustomerID", dbText, 10) ... and a multi-field index, see the CreateIndexesDAO() function here: ... create a relation (primary key to foreign key.) ...
    (microsoft.public.access.formscoding)
  • Re: Need help in my code
    ... This is my first project I work in, and I need help to solve a problem ... of entered data are defined as primary key or unique fields and should ...
    (comp.lang.java.programmer)