Fix database / tables in subreports; accept second argument for output filename