Close Current Database (1 Viewer)

Roni Sutton

Registered User.
Local time
Today, 18:47
Joined
Oct 18, 1999
Messages
68
I have dimmed app1 as a New Access Application. I open app1 usint app1.opencurrentdatabase [field in a table] (I am using a recordset and looping through). When I am finished doing what I want to do (automated, not user interfaced) in the database, I want to close both it AND the instance of Access that it loaded. I have app1.closecurrentdatabase in the code, but it is not closing the database or that instance of Access. Is there another, better way of closing out ONLY the database and instance of Access associated with app1?

Thanks, Roni
 

kaspi

Registered User.
Local time
Today, 18:47
Joined
Nov 22, 2000
Messages
60
Hi Rony
What you are doing should work (at least it works for me). Just make sure that you set all the object variables to nothing and then close the database.
If you cannot get it working send me the code and I have a look at it.
Jiri
 

Roni Sutton

Registered User.
Local time
Today, 18:47
Joined
Oct 18, 1999
Messages
68
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
 

Roni Sutton

Registered User.
Local time
Today, 18:47
Joined
Oct 18, 1999
Messages
68
DUH...I figured it out. App1.docmd.quit then set app1 = nothing does the trick. Thanks for responding, Jiri!

Roni
 

Users who are viewing this thread

Top Bottom