HELP! - Autonumbering Problem

  • Thread starter Thread starter Jody
  • Start date Start date
J

Jody

My database has linked tables. I have 10 users that have
a copy of the database on each of their computers. The
main tables reside in a shared department area on our
network. We "split" the database in order to allow more
than one individual to have the data entry forms open at a
time.

It seemed to be working but I recently noticed that when a
new record is added, instead of the system assigning the
next autonumber in the table (Activity_ID is my primary
key and autonumber field) which in this case should be
513, it tries to assign a 270 which already exists and I
get the following error message:

"The changes you requested to the tabe were no successful
because they would create duplicate values in the index,
primary key or relationship...."


I thought it should automatically put the next number on
the record.

Here's my code to add the new record.
Private Sub CmdAddActivity_Click()
On Error GoTo Err_CmdAddActivity_Click


DoCmd.GoToRecord , , acNewRec

Exit_CmdAddActivity_Click:
Exit Sub

Err_CmdAddActivity_Click:
MsgBox Err.Description
Resume Exit_CmdAddActivity_Click

End Sub

I fairly new to VB and not sure what's happening .... any
suggestions?
 
Sounds like a corruption problem to me.
Make a copy of your back end database just in case,
then run compact/repair on the original.
Chances are good that will take care of it, but if it doesn't, post
back.

HTH
- Turtle
 
I ran compact/repair but it still doesn't work. It may be
the way I have my data entry forms set up.

When the user first opens the data entry screen they are
prompted to enter their name from a drop down box. They
then click a "next" button to take them to the main data
entry screen. This screen will show all their
travel/activity entries in a list box at the bottom of the
screen. When they click on any item in the list box, they
can edit it the form at the top of the screen. I have a
button that will allow them to add a new activity.

What may be happening is that it tries to assign the next
autonumber based on the records in the listbox rather than
the entire table. How do I get the "add new activity" to
work properly by taking out the next autonumber in the
table yet still show only the selected users activities in
the listbox?

Thanks for your help.

Here's my listbox code:

Private Sub List53_AfterUpdate()
' Find the record that matches the control.
Dim RS As Object

Set RS = Me.Recordset.Clone
RS.FindFirst "[Activity_ID] = " & Str(Me![List53])
Me.Bookmark = RS.Bookmark
End Sub
 
Back
Top