database lock files

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

I have a MS Access 200 application when the user has the front end and the
tables are linked tables to other MS Access databases. When the users open
the front-end, the linked table database has a lock file created - ie, .ldb

The linked tables are created every evening by our manufacturing system.
ie - our mfg system exports an access database with the tables each night.

The manufacturing system is a proprietary format so I have to use its export
function. The manufacturing system cannot export if someone has the front
end open and a lock file exists for the linked database.

Problem is of course that users never close the front end. Would there be a
fairly simple way in the front end that I can have it close down for the
users at say 1am every day?
 
I'd be interested to see if anyone comes up with a better way of doing it
than this, but it should be possible to build in a 'self-destruct'
mechanism.

In the form load...

dim d as date
'Add 25 hours to today's date - which will give you 1 tomorrow morning
d=dateadd("h",25,date())
dim i as long
'Figure out how many seconds there are until then
i=datediff("s",now(),d)
'And set the forms timerinterval to that number (in milliseconds)
me.timerinterval=i*1000

and in the forms timer event...
docmd.quit acquitsavenone

That does leave a hole where the form is opened before 1am in the morning,
but it's easily plugged if you're worried about it.
 
In a Previous life I did the same kind of thing using an always open form.
Here is the code I used in the forms Timer event.

Static blnRunOnce As Boolean

If blnRunOnce = False Then
blnRunOnce = True ' First time Through
Me.TimerInterval = 600000 ' Check the Timer once every 10 minutes
DoCmd.MoveSize -60, 0 ' Reposition Form
cmdCust_Click ' Load Customer Form
Else ' Kill App if running betweein Midnight and 1 AM
If Time > CDate("12:00:00 am") And Time < CDate("01:00:00 am") Then
DoCmd.Quit
End If
End If

This form was a always open switchboard that had 4 or 5 buttons on it. The
timer even was set to fire 1 second after the form was loaded Where upon it
changed the the timer interval to fire once every ten minutes, then moved
itself to the upper LH corner of the app, and opened the default form for
the app. It also sets a static variable so that this initalization code
only fires once. There after when the event fires it just check to see if
it is time to unload that application.

This simple bit of code solved all of my overnight updates for 3 or four
years untill the application was retired.
 
Back
Top