I use this code to append one record at a time to a new record in a table and it works 100%. Instead of this, I would like to append all the records currently captured and filtered using the Racename field (as it is happening now), but using a button when i exit the Racesetupf form. In other words, append these records as a batch and not as single records. How do i change this code to accomplish it?
Code:
Dim MyDB As DAO.Database
Dim rstEntry As DAO.Recordset
Set MyDB = CurrentDb
Set rstEntry = MyDB.OpenRecordset("RaceEntry2", dbOpenDynaset, dbAppendOnly)
With rstEntry
.AddNew
![Racedate] = [Forms]![RaceSetupF]![RaceTimingSF]![Racedate]
![RaceName] = [Forms]![RaceSetupF]![RaceTimingSF]![RaceName]
![RaceNo] = [Forms]![RaceSetupF]![RaceTimingSF]![RaceNumber]
'Lap Numbers must be in sync with Field Names in RaceEntry
.Fields("Lap" & CStr([Forms]![RaceSetupF]![RaceTimingSF]![LapNo])) = [Forms]![RaceSetupF]![RaceTimingSF]![RaceFinishTime]
'The [RaceName] Field in RaceEntry is a LONG, so you must look up the corresponding Value
![RaceName] = DLookup("[RaceDetailID]", "RaceDetail", "[RaceName] = '" & [Forms]![RaceSetupF]![RaceName] & "'")
.update
End With
rstEntry.close
Set rstEntry = Nothing