I don't use Access, so this has not been tested in Access. It has been tested in Excel and PowerPoint. See the attached zip file which contains the following files:
a. ExcelForumFindDateInNewExcelInstance.xls - File that contains a Macro to find a Date in the Excel Data File (in another instance of Excel) and Delete all rows in the Excel Data File after the 'Date'.
b. ExcelForumFindDateInNewExcelInstance.ppt - Same as the previous file, but runs from PowerPoint. Code is identical except for the items in red below.
c. ExcelForumFindDateInColumnADataFile.xls - The Data File.
d. ExcelForumFindDateInColumnADataFileMaster.xls - Master Copy of the 'Data File' which can be used to make a fresh 'Original Copy' of the 'Data File', if the 'Data File' gets modified.
Code follows:
It is a best practice to declare all variables. If you misspell a variable in your code, VBA will silently assume it is a Variant variable and go on executing with no clue to you that you have a bug. Go to the VBA development window, click Tools, Options, and check "Require Variable Declaration." This will insert the following line at the top of all new modules:
This option requires all variables to be declared and will give a compiler error for undeclared variables.
Lewis
Bookmarks