Error 2046 acCmdRecordsGoToNew (1 Viewer)

Royce

Access Developer
Local time
Today, 17:01
Joined
Nov 8, 2012
Messages
99
I'm posting this in case it might help someone else tracking down weird 2046 errors, which there seem to be a lot of.

I was getting an error 2046 at the lines
Code:
With Me[INDENT]      If Not NewRecord Then
          DoCmd.RunCommand acCmdSaveRecord
          DoCmd.RunCommand acCmdRecordsGoToNew
      End If
[/INDENT]End With
As the code worked fine at one site, but failed at another, I suspected a backend problem.

It turned out the backend database did not have the PrimaryKey set for the table, and there was a weird corrupted record with a null in the field that should have been the Primary Key, and garbage in the other fields. I set the Primary Key, deleted the garbage records and problem went away.
 

essaytee

Need a good one-liner.
Local time
Tomorrow, 08:01
Joined
Oct 20, 2008
Messages
512
I'm posting this in case it might help someone else tracking down weird 2046 errors, which there seem to be a lot of.

I was getting an error 2046 at the lines
Code:
With Me[INDENT]      If Not NewRecord Then
          DoCmd.RunCommand acCmdSaveRecord
          DoCmd.RunCommand acCmdRecordsGoToNew
      End If
[/INDENT]End With
As the code worked fine at one site, but failed at another, I suspected a backend problem.

It turned out the backend database did not have the PrimaryKey set for the table, and there was a weird corrupted record with a null in the field that should have been the Primary Key, and garbage in the other fields. I set the Primary Key, deleted the garbage records and problem went away.

For the backend data file in question do your users have easy access to it. That is, can they navigate the tables, have a browse etc. Have you got anything in place to help alleviate problems caused by users with little knowledge.
 

Royce

Access Developer
Local time
Today, 17:01
Joined
Nov 8, 2012
Messages
99
The users don't know the back end exists. They never see a table, queries, or any of the behind the scenes stuff. Error trapping, and logging, is used, and I examine the logs from time to time for hidden problems. In this case, the only symptom was you couldn't add a new record via a subform. You could add records in another form that used the same table as the record source.

There was a corruption problem a while back, a compact and repair "fixed" it. But I suspect this problem was related.
 

Users who are viewing this thread

Top Bottom