I have several subroutines in my Access 2013 application that write to the same output table. Currently each subroutine opens the output recordset, writes records to it, then closes it.
There are six subroutines and the are executed hundreds of time from a processing loop.
This processing takes a very long time and I am looking for ways to improve the time.
The processing loop and subroutines are all contained in the same module.
Option Compare DatabaseOption ExplicitDIm wkVar as string.. other module wide definitions.private sub outsideProcessingLoop()'' Can I open the output file here one time such that the called subroutines can write directly to it, wthout having to open and close 'it every time?'Do while ..... processSomeRecords() processOtherRecords()enddo end sub' Typical handling of output file in each of the processing subsprivate sub processSomeRecords()'Set db = getCurrentDbCDim rsOut As DAO.RecordsetSet rsOut = db.OpenRecordset(outputTable, dbOpenDynaset, dbSeeChanges).. processing logic.'rsOut.CloseSet rsOut = Nothingend subprivate sub processOtherRecords()'Set db = getCurrentDbCDim rsOut As DAO.RecordsetSet rsOut = db.OpenRecordset(outputTable, dbOpenDynaset, dbSeeChanges).. processing logic.'rsOut.CloseSet rsOut = Nothingend sub
Is there a way I can define the output file in the header of the module, above all subs and/or functions, so that I will only open it once and all the subroutines can write to the open output file without having to open and close it?