?
Solved

Unable to kill access MDB file at run time

Posted on 2003-03-06
4
Medium Priority
?
252 Views
Last Modified: 2013-12-25
Hi,

I am using DAO 3.6 to create an access MDB at the run time and populating the table. When i try to kill the mdb for next round of operations I get 'Path/File access error'. I am closing the database everytime I open it. I don't want to close my application for each operation.

How to avoid this error ? Your help is highly appreciated
0
Comment
Question by:srikanthnama
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 

Accepted Solution

by:
_Merlin_ earned 60 total points
ID: 8078422
Don't use the dataconnection control. Link to your database using code. That way you can unlink the database and kill it, rename it or whatever.

example:

Public cn_MyDb As ADODB.Connection
dim str_DatabasePath as string

Set cn_MyDb = Nothing
Set cn_MyDb = New ADODB.Connection

str_DatabasePath = "C:\Database\MyDb.mdb"
' You can assign the databasepath a value by using a common dialog and store the value in the registry for next runs.
' If the database can't be found, call the commondialog again to locate it and store the new value in the registry.

cn_MyDb.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & str_DatabasePath

' Perform actions to the db.

' disconnect the database
Set cn_MyDb = Nothing

' Now you can kill it or whatever.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 8088579
If you only use Access, you need 2 "databases": 1 for the front-end, and one for the data store.
0
 
LVL 1

Expert Comment

by:Balshe
ID: 8362125
see this sub

Sub CompactDB()
Dim DbName As String
DbName = Db2.Name
Db2.Close
Caption = "Compacting"
Dim X As String, DbFile As String, Dbpath As String
Dim pos As Long
X = DbName
pos = InStrRev(X, "\")
DbFile = Mid(X, pos + 1, Len(X))
Dbpath = Mid(X, 1, pos)
X = Dbpath & "XX" & DbFile
DBEngine.CompactDatabase DbName, X
Kill DbName
Name X As DbName
Set Db2 = DBEngine.OpenDatabase(App.Path & "\School.mdb")
End Sub
0
 
LVL 2

Expert Comment

by:cerebralpc
ID: 9026016
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept  _Merlin_  comment as answer.

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
cerebralPC
EE Cleanup Volunteer
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question