You don't need a new table, the only thing you're missing is a sequence number which you can store in your original table and generate the 'id' field whenever necessary. Unless you have a specific reason to create a new table with the exact same data in a different layout I would try to stay away from creating temp tables because every time you add data you'll be, potentially, re-sequencing data which may not be what you're after.
So let's say you have
Code:
tblTest
T_ID T_Date T_Desc
1 3/23/2016 AAA
2 3/23/2016 CCC
and you run your procedure to sequence these in a new table then you add a new record
Code:
tblTest
T_ID T_Date T_Desc
1 3/23/2016 AAA
2 3/23/2016 BBB
3 3/23/2016 CCC
Unless you have a reliable way to sort your records (for instance going on the T_ID field) you may get a result where in the first example you'll get a sequence number of 1 for the AAA record and 2 for the CCC record, in the second example you'd get a sequence number of 1 for the AAA, 2 for the BBB and 3 for the CCC record.
It'd be far easier to determine the sequence number at the time of data entry rather than what you're trying to do.
That being said
you could use something like
Code:
dim rst as recordset
dim iSeq as long
dim dPrevDate as date
dim dCurrDate as date
set rst = currentdb.openrecordset("SELECT * FROM tblTEST ORDER BY T_Date, T_ID")
iSeq = 0
dPrevDate = rst!T_Date
do while rst.eof <> true
dCurrDate = rst!T_Date
if dCurrDate <> dPrevDate Then
iSeq = 1
else
iSeq = iSeq + 1
end if
currentdb.execute ("INSERT INTO tblTemp (SequenceConverted) VALUES ('" & datepart("yyyy", rst!T_Date) & format(datepart("m", rst!T_Date), 00) & format(datepart("d",rst!T_Date), 00) & format(iseq, "000") & "'")
rst.movenext
loop
set rst = nothing