Hey,

I've a table in access with an index that is not an autonumber. I'd like to append new records to this table based on another table.

I've tried writing a query for that, and have put dmax("Index","MyTable") +1 as the index for the records. that only works for the first record. so I've tried writng a small vba for that using dao which completely doesnt work:


Set qdf1 = CurrentDb.TableDefs("Import_budgets")
Set rs1 = qdf1.OpenRecordset
rs1.MoveFirst

Set qdf2 = CurrentDb.TableDefs("budget_lines")
Set rs2 = qdf2.OpenRecordset
Index = DMax("budget_line_no", "budgets")
'qdf("station") = Me.station_no

While Not (rs1.EOF)
Index = Index + 1
rs2.AddNew
rs2.budget_line_no = Index
rs2.budget_no = Me.sel_budget_no
rs2.payment_type_no = Me.Sel_Payment_Type
rs2.station_no = rs1.Istation_no
rs2.amount = rs1.budget

rs1.MoveNext
Wend