Let's assume you have these tables:
Code:
Tbl_Maps
MapID MapName MapLines
1 Map A 9
2 Map B 7
3 Map C 5
Tbl_MapLines
LineID (autonumber primary key)
MapID (inherited from tbl_maps)
LineNumber (starts at 1, ends at maplines)
The code you would use (either by creating a module, addiing it to the ON CLICK EVENT of a button, etc) is this
Code:
dim db as database
dim sSQL as string
dim rst as recordset
dim iMapID as long
dim iTotalLines as integer
dim iCurrLine as integer
set db = currentdb
ssql = "SELECT * FROM Tbl_Maps"
'you may enter a criteria if you are doing this for one map at a time
'when running this code you also want to make sure you are only running
'for maps that have no lines generated in the Tbl_MapLines table
set rst = db.openrecordset ssql
iCurrline = 1
do while rst.eof <> true
iMapID = rst.fields("MapID")
iTotalLines = rst.fields("maplines")
for i = 1 to itotallines
ssql = "INSERT INTO Tbl_MapLines (MapID, LineNumber) VALUES (imapid, i)
db.execute ssql
i = i + 1
next i
rst.movenext
loop
rst.close
set db = nothing
NOTE: I didn't test this fully but if I've missed something post back