UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Opening Another Database From Access, Access 2016    
 
   
tpitman
post Apr 2 2020, 01:25 PM
Post#1



Posts: 637
Joined: 20-June 04
From: UK


Hi I use the following code to open another database.

It works, however, if I include Application.quit, it closes the both databases. If I leave it out, a database window is left open each time. How can I make sure the database window of the appaccess object is closed but the maindatabase left running?

CODE
Function SaveGHTemps()
Dim appAccess As Access.Application


Set appAccess = CreateObject("Access.Application")

appAccess.OpenCurrentDatabase "C:\Users\bztjp\OneDrive - University of Bristol\Glass Databases\Temperatures.accde", False

appAccess.Run "AddData"
appAccess.CloseCurrentDatabase

Application.Quit

Set appAccess = Nothing

Go to the top of the page
 
vtd
post Apr 2 2020, 01:52 PM
Post#2


Retired Moderator
Posts: 19,777
Joined: 14-July 05
From: Sydney NSW Australia


Try:
CODE
Function SaveGHTemps()
Dim appAccess As New Access.Application


Set appAccess = CreateObject("Access.Application")

appAccess.OpenCurrentDatabase "C:\Users\bztjp\OneDrive - University of Bristol\Glass Databases\Temperatures.accde", False

appAccess.Run "AddData"
appAccess.CloseCurrentDatabase

appAccess.Quit

Set appAccess = Nothing


Note the changes in the Dim statement and Quit statement.
Go to the top of the page
 
tpitman
post Apr 2 2020, 02:23 PM
Post#3



Posts: 637
Joined: 20-June 04
From: UK


Thanks for answering.

Ive tried your amended code. “AppAccess” now partially closes but “hangs” and i have to use <Ctrl>/<alt>/<del> to close it
Go to the top of the page
 
isladogs
post Apr 2 2020, 04:45 PM
Post#4


UtterAccess VIP
Posts: 2,311
Joined: 4-June 18
From: Somerset, UK


I have similar code which works fine.
Just wondering whether the issue is that you are opening an Access db on OneDrive

Using any online storage for an Access file isn't recommended as any interruption in connection can cause corruption.

Try this code with an external database on your local drive and then on a LAN drive.

--------------------
Colin (Mendip Data Systems)
Website, email
Go to the top of the page
 
tpitman
post Apr 11 2020, 06:54 AM
Post#5



Posts: 637
Joined: 20-June 04
From: UK


Yes it did seem to be an issue with onedrive, so I am now saving it to localdrive

Works fine now

Thanks for all your help
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    30th May 2020 - 11:59 PM