Jiri,
I think I know what the problem is, but can't seem to get around it. The database that I am opening and attempting to close has been set up to not allow the user to close using the 'x' button. There is a login form and they can click on an "Exit Database" button without logging in, but can't close the usual way. I believe that is what is stopping me. I have tried setting the focus to the Exit Database control on the form, but access says it can't find the control. I did that with the command
app1.forms!frmRecsEX2!command18.setfocus. (command18 is the name of the control - quite imaginative, huh?) I checked and rechecked that I had spelled everything correctly, but it didn't like it. Then I thought about doing sendkeys to the form. I could send enough tabs to get to the exit button and then send and enter. That doesn't seem to work either. I can't find a command that tells the code to send the keystrokes to app1. app1.sendkeys and app1.set focus give me a "method or data member not found" error. Every idea I've had on this has stymied me. The owner of the databases that I am trying to close said he will turn off the inability to close using the x if he has to, but he really doesn't want to. Do you have any ideas on how to either send keys to the open db form or set the focus to the exit button? OR perhaps turn off the property that doesn't allow me to close the db in my code so that it doesn't change his db except when I am running this program? (He's on vacation, I can't ask him.)
Thanks, Roni