By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,479 Members | 1,229 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,479 IT Pros & Developers. It's quick & easy.

Access is not deleting the .ldb file

P: 69
I searched for this topic on TheScripts but didn't see any earlier posts. Here are the basic facts of my problem:

* I've deleveloped an Access 2002 database (.mdb) that contains many tables and forms
* The project is secured with user level security (i.e. a .mdw file) so users must log in to use the database
* Multiple users have been able to successfully use the database simultaneously
* Whenever a user opens the database, Access creates a ".ldb" file to facilitate record level locking

PROBLEM: It seems when the last user exits the database, Access is not deleting the .ldb file like it's supposed to. While this doesn't hinder users from continuing to use the database, it does prevent me (the admin) from opening the database file for exclusive use so that I can make updates to (and fix bugs on) the forms.

How do I clear/delete the .ldb file? Is this a known problem with Access?

Thanks for reading this post and passing along any insight you may have.

Scott
May 23 '07 #1
Share this Question
Share on Google+
4 Replies

P: 69
Nevermind. The problem wasn't Access. The problem was a user who continually left the database open (even when he went home at night). This meant that Access couldn't delete the .ldb file.

Sorry for troubling everyone.
May 24 '07 #2

NeoPa
Expert Mod 15k+
P: 31,770
No problem Scott.
An interesting question, and thanks for posting the answer.
I had a feeling that it was in the OS area rather than Access (as I'd not come across this behaviour before). This is one for user education. I have some thumb-screws to lend if you need a set :D
May 24 '07 #3

P: 11
Nevermind. The problem wasn't Access. The problem was a user who continually left the database open (even when he went home at night). This meant that Access couldn't delete the .ldb file.

Sorry for troubling everyone.
Scott -

I know this thread is a little old at this point, but it may be helpful to other users who run into this problem. I had the same issue with users leaving the database open all the time and I couldn't do updates to the database. To solve this, you can setup a timer to run when the database is opened by each user. After the set time, the database saves everything and closes.

To do this you can create a blank form (I called mine "DetectIdleTime") and under the form's properties, set the Timer Interval to 1000 and create the following procedure for the OnTimer property (I have the idle time set to 45 minutes).

Once you have the form created, you can create a macro to run on startup called AutoExec. Set the form name (mine was DetectIdleTime) and the view as "form" and the window mode as "hidden". This will allow the timer to run in the background and if the user is inactive for the set time, then it closes.
Code (text)

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Timer()
  2.     'IDLEMINUTES determines how much idle time to wait for before running the
  3.     'IdleTimeDetected subroutine.
  4.     Const IDLEMINUTES = 45
  5.  
  6.     Static PrevControlName As String
  7.     Static PrevFormName As String
  8.     Static ExpiredTime
  9.  
  10.     Dim ActiveFormName As String
  11.     Dim ActiveControlName As String
  12.     Dim ExpiredMinutes
  13.  
  14.     On Error Resume Next
  15.  
  16.     'Get the active form and control name.
  17.  
  18.     ActiveFormName = Screen.ActiveForm.Name
  19.     If Err Then
  20.         ActiveFormName = "No Active Form"
  21.         Err = 0
  22.     End If
  23.  
  24.     ActiveControlName = Screen.ActiveControl.Name
  25.     If Err Then
  26.         ActiveControlName = "No Active Control"
  27.         Err = 0
  28.     End If
  29.  
  30.     'Record the current active names and reset ExpiredTime if:
  31.     '   1. They have not been recorded yet (code is running for the first time).
  32.     '   2. The previous names are different than the current ones (the user
  33.     '       has done something different during the timer interval).
  34.     If (PrevControlName = "") Or (PrevFormName = "") _
  35.         Or (ActiveFormName <> PrevFormName) _
  36.         Or (ActiveControlName <> PrevControlName) Then
  37.             PrevControlName = ActiveControlName
  38.             PrevFormName = ActiveFormName
  39.             ExpiredTime = 0
  40.     Else
  41.         '...otherwise the user was idle during the time interval, so increment
  42.         'the total expired time.
  43.         ExpiredTime = ExpiredTime + Me.TimerInterval
  44.     End If
  45.  
  46.     'Does the total expired time exceed the IDLEMINUTES?
  47.     ExpiredMinutes = (ExpiredTime / 1000) / 60
  48.     If ExpiredMinutes >= IDLEMINUTES Then
  49.         '...if so, then reset the expired time to zero...
  50.         ExpiredTime = 0
  51.         '...and call the IdleTimeDetected subroutine.
  52.         IdleTimeDetected ExpiredMinutes
  53.     End If
  54. End Sub
  55.  
  56. Sub IdleTimeDetected(ExpiredMinutes)
  57.     Application.Quit acQuitSaveAll
  58.  
  59. End Sub
Jun 18 '07 #4

NeoPa
Expert Mod 15k+
P: 31,770
Thanks for posting this code.
This could prove very useful to a number of our members, so is much appreciated.

Anyone using it should bear in mind that a user continually hitting the same button would be considered by this code to be inactive. In all other circumstances that I can think of this would work well for anyone interested in such a routine.
Jun 19 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.