It seems that, if tables PEI and HISTORY are not open before the function is called, they will be closed every time. You will gain speed if you either don't close tables that often or if you open them before calling the function.
Gensoft Sàrl
Christian Carron