Microsoft Access Reusing Record ID's - ms-access

I have a (Microsoft access office 365 database). I have a number of records in a table in the database. Lets say I have 5 records numbered 1 to 5 respectfully. now when I delete record number 3. Record number 3 is now gone. The problem I am having is when I create a new record I see that record number 3 is being used again as a record number despite the fact that record number 3 has been deleted. This to me should not be happening. I recently upgraded the Microsoft Access Database Engine redistributable 2016 on our server from 2010. Thinking this might resolve the problem. The data type and primary key for the archiveID field is AutoNumber.
Please advise.

Some times AutoNumber can be damaged, for example by manual assignment. Try to repair it:
INSERT INTO [TableName]([archiveID]) SELECT MAX([archiveID]) FROM [TableName];
And check if problem repeats.

Related

ODBC - insert on a linked table failed

I have the Front_end in the MS-Access and the database is on theserver. Have connected the database with the ODBC connecter.
I have attached the sub-form under the form. and assign the TAb. while adding the new Record, when I clicked on the form it is showing me this error ODBC - insert on a linked table failed. (Error 3155). The error just pops out while clicking every on the table. even when I click on the close button, before closing the window this popup comes ODBC - insert on a linked table failed. (Error 3155). Dont know how to rid off from this trouble shoot.
Important Note:
The Main form has the table linked - tblInvoices ( This table is the parent table of
the tblInvoiceDetails.
SubForm under the main form has the Linked table - tblInvoiceDetails - this table is
linked with the parent table tblInvoices.
When i m entering the some data on main Form, and then press enter to go under Subform
then this popup appears ODBC - insert on a linked table "tblInvoices" failed.
tblInvoices has a large amount of data ~1m rows.
tblInvoiceDetails has a large amount of data ~2M rows.
In tblInvoiceDetails there is the foriegn key which is refer to the tblInvoices
Unique key.
Have Tried:
Have recreated the database with the new tblInvoices and
tblInvoiceDetails with limited rows.
In tblInvoices and tblInvoiceDetails we have added and checked the primary key in each table.
Screen Shots:
If anything you professionals required then please let me know. will share you.
Thank you. for your help.
The error is not with respect to Ms-access its the limitation to ODBC connector.
sql - Issue with ODBC Object connection - Open limitation to 65k rows - Stack Overflow.
Please read : Issue with ODBC Object connection - Open limitation to 65k rows
This works for me:
Older Excel versions (prior to 2007) indeed have a limit of some 65k+
rows per worksheet. Run your code and reference any object Lib
starting w/Excel 2007 and up (max 1,048,576 rows per worksheet, Lib
version correspondingly 12.x and up).
Have Change the Provider = Microsoft.ACE.OLEDB.12.0 with Microsoft.ACE.OLEDB.16.0. Update the lib with the higher version & Latest version.
Thanks.

Rows keep showing #DELETED

Everytime I enter data into one of the SQL linked tables, some of the rows keep saying #deleted no matter what I do. The data is fine in the actual SQL server but not within Access. I never have used Access before so I have no idea what I'm doing. Please use the most non-tech savy dialog as possible... This is all so new to me and I am not good with technology at all.
I have tried refreshing the tables by going to the "Linked Table Manager" thing but that hasn't helped. I tried completely deleting the data from both Access and the SQL Server, re-entering it into the SQL server, and creating a new linked table within Access. I have tried exporting the data into Excel from the server and importing it into Access. None of it has worked. It's only the first 10 rows of data though... The rest of the table is completely fine and all the data has similar structure so I don't know why only the first 10 rows are being affected.
Ok, there are 3 things that often cause this.
1 - Make sure the sql table has a PK column. This is often (useally) a autonumber (incrementing by 1 integer column). So when you create the column in sql server, set it as primry key (a button in the menu can be hit to set PK using the sql manager). Then change in the property sheet the column to identify "yes" and it will set the starting number (1) and the increment (1) for you. Now add the other columns.
So Access needs a PK column.
If above was not your issue, then next up that is common is if you have a "bit" column in sql eerver. These can't be null, or access goes crazy. so if you have a bit column, then MAKE sure you set the default for that in the sql table designer as (0).
If the above don't fix your issue? Then number 3 on the list is to add what is called a row version column to the sql table. Simply add a timestamp column (this is NOT a date column, but is a time stamp row).
In ALL of the above cases, after you make the change to the sql server table, you have to re-link the access table. It is sufficient to right click on the table in Access, choose linked table manager, and then check box the table in queston, and hit ok. The link will be refreshed for you.
So the above are the 3 main issues. In most cases, the PK is the issue. However, if the table on SQL also has a trigger (that inserts) to other tables, then that table trigger has to be changed - but lets take this 1 step and soluion at a time.
As a general rule, Access needs a PK column when working with sql server. If you have that, then check the null "bit" issue - sql server tables need a default setting of 0 for those columns, and if they are null, then Access don't like that.
If both above issues are NOT your issue, then adding a column of timestamp to the sql table will fix this.

Microsoft Access linked table (ASE) with trigger error

I have in Microsoft Access a linked table to an ASE Server.
On the server side, the table has no primary key or identity columns.
And has a trigger on insert that validates new entries, so that when the entry is not validated it deletes the entry from the table and writes to "table"_ERR to let the users know what error was produced.
When linking it to Access a composite key is created using 10 columns.
I have this same setup in 10 different tables (all with triggers all linked to Access)
In this particular table when trying to insert/append records to the table through Access i always get the error message:
Single-row update/delete affected more than one row of a linked table. Unique index contains duplicate values.
This error occurs when both table and table_ERR are empty and i'm only trying to insert 1 record.
If I disable the trigger i have no problem inserting records through Access
I have similar triggers in other tables that are working correctly.
What can be causing this issue and does anyone know how to solve this?
I have read that MS Access can mess up the ##identity, even so none of the solutions presented online seem to work.
links : https://groups.google.com/forum/#!msg/microsoft.public.sqlserver.programming/McHdRpPKMhs/SlyObU8w7JMJ
Stop Access from using wrong identity when appending to linked table on SQL server
Thanks in advance.
EDIT: if i try to insert the records directly from a management software (like Aqua Data Studio) there are no erros
Without knowing more specifics about your data itself, it is difficult to say why this might be happening.
However, it sounds like in this specific instance for this specific linked table, your 10 columns are not unique enough to prevent non-distinct rows from being selected.
Suggested fixes:
Add a primary key. Honestly, probably the best and easiest choice.
If for some reason you cannot add a new column to (or alter) your table; you may be able to re-link your table, and re-choose your 10 columns so that they are more unique.
Beyond that, I think we would need more information.
Just out of curiousity, what is the reason for having no key?

MS Access 2000 (*mdb) default value of Now() sometimes fails?

Is there a known failure mode of a MS Access 2000 database, when data is refused (or silently discarded, which is worse) to be inserted into a table containing a Date/Time type of field with default value of =Now() ?
The date/time field in question is not indexed or required;
But when an INSERT query is sent to the database, it looks like the =Now() function fails - and the data is not written to the table (however another auto-increment field lookup is executed, because, when later on =Now() succeeds, there is a gap in auto-increments, equal to the number of times the query was run)
e.g. i see in the table
ID | Data | Timestamp
5 | foo | 11/15/2016 17:15:00
1 | foo | 11/15/2016 17:11:00
when an INSERT INTO TheTable ([Data]) VALUES (foo) is ran every minute and the problem happens on run 2, 3 and 4. Eventually after some time, it succeeds (as shown with ID=5)
Why do I think it could be the =Now() problem ?
Because same/similar failure happens if computer clock is changed /backwards/ (e.g. during DST adjustment).
But it has recently happened just out of the blue, not being able to write data to that table for a couple of hours, when the DST adjustment has actually happened already.
(the program itself is not being told of the query failure and charges forward as if nothing happened - some debugging effort is pending still)
I looked about SO and wonder if this Table Field Default Property Values Functions Not Working Anymore in Microsoft Access 2010 may have something to do with it? However the program and the database communicate via ODBC Microsoft Access (*.mdb) driver (yes MS Office 2000 files...)
Hope this makes sense,
Kind Regards...
Have never heard of such issue, but why not just adjust your SQL:
INSERT INTO TheTable ([Data], [Timestamp]) VALUES (foo, Now())

How to reset Access 2007 autonumber at certain row

I have an Access 2007 database schema where the central table has a primary key which is an auto number. I have to delete records I input in the foreign table to re-input them and so want to delete the parent reference from the central table. What I want to know is how can I set the cebtral table autonumber to start counting again from before I input the records the first time? That is before I input the records the autonumber was at 2380 but now is at 2523, if I delete all after 2380 how do I get the auto number to restart again at 2381 when I insert the records again
After you delete the rows from the specified table you need to do a "Compact and Repair Database" operation on the database file. That will have the effect of resetting the next AutoNumber value to (the_current_largest_AutoNumber_value + 1).
For details on how to do a "Compact and Repair Database" in Access 2007, see the "Manually compact and repair a database" topic in the following Microsoft Support article:
Help prevent and correct database file problems by using Compact and Repair