Thanks John/David,
I've managed to export all the data and import it into a new table.
I have all my ID numbers in a Long Integer number field now. What I'd like
to do is generate this so-called Auto-number (as per David's code) whenever I
click on the "New" command button on one of my forms. I'd like to have the
new number generated ONLY when we click on that button. If I were to add the
code in the On Open event, for example, a new number would be generated any
time I opened that form.
The following code gives me a "Sub or function not defined" error:
Private Sub cmdAddRecord_Click()
On Error GoTo Err_cmdAddRecord_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmRunningTasksAddNewRec"
DoCmd.OpenForm stDocName, , , stLinkCriteria
[txtID] = MAX([tblRunningTasks]![ID]) + 1
Exit_cmdAddRecord_Click:
Exit Sub
Err_cmdAddRecord_Click:
MsgBox Err.Description
Resume Exit_cmdAddRecord_Click
End Sub
I know I'm close, almost there. Or would you guys suggest I do this some
other way?
John Vinson said:
As David says... you should NOT be using Autonumbers for this purpose.
You just found out one reason why... <g>
Did you Replicate the database recently? If so, it will change all
Autonumber fields to Random. Each new autonumber will be somewhere in
the range -2^31 to +2^31-1. Or, somehow the table definition might
have been changed to make the autonumber field Random.
I would suggest creating a new table with a Long Integer primary key;
run an Append query to migrate your existing data into it. You'll be
able to edit this record in the new table. You will need to
reestablish all your relationships (dropping them from the old table
and creating new ones from the new) and follow David's advice about
programmatically assigning new ID numbers.
John W. Vinson[MVP]