J
JulieD
Hi All
i know i've done this before, but can't remember how -
i have a form - based on a table (tbl_Assignments) - with a primary key
field (primary key made up of two fields) called AssignNum (long integer).
What i do is when the user picks a value from a combo box, i run an append
query to append a series of records into the tbl_Assignments and then
display this information in the form so that they can modify it. As
AssignNum is a primary key field, i populate it initially with the value of
another field in the select / append query. But then i would like to cycle
through the records and renumber the AssignNum field starting from 1 each
time (this is before they are used anywhere else).
i'm guess that i need to use a select query to drag out the records that
i've just appended (sorted in the order that i want) and then cycle through
the recordset updating each record in turn - it's this last bit i can't get.
the bit of code i need help with (i think) is:
strsql = "SELECT jTBL_ClassAssignment.ClassID,
jTBL_ClassAssignment.AssignNum, jTBL_ClassAssignment.AssignmentSortID FROM
jTBL_ClassAssignment WHERE jTBL_ClassAssignment.ClassID = " & intclassid & "
ORDER BY jTBL_ClassAssignment.AssignmentSortID;"
Set rst = dbs.OpenRecordset(strsql, dbOpenDynaset)
rst.MoveFirst
i = 1
For Each ??????? in rst
rst("AssignNum") = i
Next
Please help
Cheers
JulieD
i know i've done this before, but can't remember how -
i have a form - based on a table (tbl_Assignments) - with a primary key
field (primary key made up of two fields) called AssignNum (long integer).
What i do is when the user picks a value from a combo box, i run an append
query to append a series of records into the tbl_Assignments and then
display this information in the form so that they can modify it. As
AssignNum is a primary key field, i populate it initially with the value of
another field in the select / append query. But then i would like to cycle
through the records and renumber the AssignNum field starting from 1 each
time (this is before they are used anywhere else).
i'm guess that i need to use a select query to drag out the records that
i've just appended (sorted in the order that i want) and then cycle through
the recordset updating each record in turn - it's this last bit i can't get.
the bit of code i need help with (i think) is:
strsql = "SELECT jTBL_ClassAssignment.ClassID,
jTBL_ClassAssignment.AssignNum, jTBL_ClassAssignment.AssignmentSortID FROM
jTBL_ClassAssignment WHERE jTBL_ClassAssignment.ClassID = " & intclassid & "
ORDER BY jTBL_ClassAssignment.AssignmentSortID;"
Set rst = dbs.OpenRecordset(strsql, dbOpenDynaset)
rst.MoveFirst
i = 1
For Each ??????? in rst
rst("AssignNum") = i
Next
Please help
Cheers
JulieD