loGrid = "" lnGridCount = 0 FOR i = 1 TO thisform.controlcount IF thisform.controls[i].class = "grid" && or your gridclass name loGrid = thisform.controls[i] lnGridCount = lnGridCount + 1 ENDIF ENDFOR DO CASE CASE lnGridCount = 0 && no grids CASE lnGridCount > 1 && too many grids CASE lnGridCount = 1 SELECT loGrid.RecordSource COPY TO < filename > TYPE XLS ENDCASEAssuming this works on simple forms there are plenty of tweaks which may be needed. You will need to tweak it if you have more than one class of grids. You will need to tweak it if you use pageframes and the grid is on one of the pages.