I have a line of code that runs "on close" of the switch board. It looks at how many times the datbase has been opened and will start a macro etc. to compact and repair the database when it closes the 10th time. The problem is , I don't know how to write the process. How do I write code, micro, etc. to compact and repair. I know there is an option to do this every time it closes, but that is to often.