G
Guest
I am using the following code to add a new record to an existing table.
If Rotation!Division = Division!Division Then
Rotation.AddNew
Rotation!Division = Division!Division
Rotation!Code = Division!Code
Rotation.Update
Rotation.MoveLast
GoSub GetStartDate
GoSub GetEndDate
GoSub WriteNameToDateField
Division.MoveNext
I use the MoveLast command to move to the record I just created the GoSub
procedures also edit the same record. Nine out of ten times the result is
exactly what I expect. However, 10% of the time the AddNew command moves the
new record to the begining of the table vice the end and the results are
unuseable. I never see this problem when I step through the program. Usually
when it does happen, I rerun the procedure again an I get the normal results.
Why does this occur and how can I make it stop?
Note: The help file says the following (Iam using a table type recordset),
The position of the new record depends on the type of Recordset:
In a dynaset-type Recordset object, records are inserted at the end of the
Recordset, regardless of any sorting or ordering rules that were in effect
when the Recordset was opened.
In a table-type Recordset object whose Index property has been set, records
are returned in their proper place in the sort order. If you haven't set the
Index property, new records are returned at the end of the Recordset.
The record that was current before you used AddNew remains current. If you
want to make the new record current, you can set the Bookmark property to the
bookmark identified by the LastModified property setting.
If Rotation!Division = Division!Division Then
Rotation.AddNew
Rotation!Division = Division!Division
Rotation!Code = Division!Code
Rotation.Update
Rotation.MoveLast
GoSub GetStartDate
GoSub GetEndDate
GoSub WriteNameToDateField
Division.MoveNext
I use the MoveLast command to move to the record I just created the GoSub
procedures also edit the same record. Nine out of ten times the result is
exactly what I expect. However, 10% of the time the AddNew command moves the
new record to the begining of the table vice the end and the results are
unuseable. I never see this problem when I step through the program. Usually
when it does happen, I rerun the procedure again an I get the normal results.
Why does this occur and how can I make it stop?
Note: The help file says the following (Iam using a table type recordset),
The position of the new record depends on the type of Recordset:
In a dynaset-type Recordset object, records are inserted at the end of the
Recordset, regardless of any sorting or ordering rules that were in effect
when the Recordset was opened.
In a table-type Recordset object whose Index property has been set, records
are returned in their proper place in the sort order. If you haven't set the
Index property, new records are returned at the end of the Recordset.
The record that was current before you used AddNew remains current. If you
want to make the new record current, you can set the Bookmark property to the
bookmark identified by the LastModified property setting.