Lock application

J

John J.

I start my app with a start.mdb which eventually opens the FE. In that
start.mdb a check is made in the backend for last_backup date. So when the
first user of the day logs on, a backup is being made. I also added code to
compact the database. The code is as follows:

1. Rename the BE to a temporary name
2. Compact (and therefore copy) the temporary BE to the original BE name.
3. Copy the compacted BE to the backup dir and delete the temporary BE.

I have added error trapping.

During the compact and backup phase no one should be allowed into the
application. I can't seem to figure out how prevent users from logging in.
If I set a flag to a lock_value in the BE's control table to True, that
value will be copied along with the BE and in the backup as well. Also,
while the BE doesn't exist for a while, the lock_value can't be read. I'm a
bit stuck.

Can someone give me a hint? Am I on the right track?
Thank you.
John
 
D

Dale Fye

The best way I've found to do this is to have a text file in the same folder
as the backend. When I get ready to do the backup you speak of, I change
the name of this file to something like "LockOut.txt", then when the backup
is done, I change it back to something else. Or you could create the file
on the fly, and delete it when you are done.

Now, when your user opens the app, check to see if the file "LockOut.txt"
exists in the same folder as the backend database. If it does, politely
tell the user that the database is in maintenance and either have them wait
(depending on how long your backup takes), or ask them to come back later.
If that filename doesn't exist, check to see if you are the first user of
the day. If so, either change the txt file name or create it, so no one
else can log in. Then do your backup stuff, and finally, delete or change
the name of the file.

HTH
Dale


When you your user logs in, the first thing you can do is check to see if
this file
 
A

Armen Stein

I start my app with a start.mdb which eventually opens the FE. In that
start.mdb a check is made in the backend for last_backup date. So when the
first user of the day logs on, a backup is being made. I also added code to
compact the database. The code is as follows:

1. Rename the BE to a temporary name
2. Compact (and therefore copy) the temporary BE to the original BE name.
3. Copy the compacted BE to the backup dir and delete the temporary BE.

I have added error trapping.

During the compact and backup phase no one should be allowed into the
application. I can't seem to figure out how prevent users from logging in.
If I set a flag to a lock_value in the BE's control table to True, that
value will be copied along with the BE and in the backup as well. Also,
while the BE doesn't exist for a while, the lock_value can't be read. I'm a
bit stuck.

Can someone give me a hint? Am I on the right track?
Thank you.
John

Well, for one thing this seems like a lot of effort to get daily
backups. Can't you use a job on your server to get backups during the
night?

For more, including automating the compaction process, you could check
out FMS Agent: http://www.fmsinc.com/MicrosoftAccess/Scheduler.html.

Doesn't each user have their own copy of the FE? They should. I
don't see how they can open the application anyway after you've
renamed the BE. I would think that they would be prevented from
successfully using the app until your step 2 was completed.

Armen Stein
Microsoft Access MVP
www.JStreetTech.com
 
J

John J.

Thanks Dale.
Good idea! Will do so.

Dale Fye said:
The best way I've found to do this is to have a text file in the same
folder as the backend. When I get ready to do the backup you speak of, I
change the name of this file to something like "LockOut.txt", then when
the backup is done, I change it back to something else. Or you could
create the file on the fly, and delete it when you are done.

Now, when your user opens the app, check to see if the file "LockOut.txt"
exists in the same folder as the backend database. If it does, politely
tell the user that the database is in maintenance and either have them
wait (depending on how long your backup takes), or ask them to come back
later. If that filename doesn't exist, check to see if you are the first
user of the day. If so, either change the txt file name or create it, so
no one else can log in. Then do your backup stuff, and finally, delete or
change the name of the file.

HTH
Dale


When you your user logs in, the first thing you can do is check to see if
this file
 
J

John J.

Thanks Armen.
The nightly backup is not an option at the moment.

Each user has his own FE. When the user opens the FE while the BE isn't
present, the FE will open anyway. Only the data can't be retrieved. Also,
while the BE IS present but still in copying status, the user shouldn't be
able to enter the app as well.
 
A

Arvin Meyer [MVP]

If you schedule your backup to run at a certain time, you can warn your
users 5 minutes, 1 minute, and 15 seconds before kicking them out. I have an
example of kickem out at:

http://www.datastrat.com/Download/KickEm.zip

You can use the FMS app as well.

Armen's suggestion of an automatic schedule to backup every night is the
most sensible. It is also what most businesses do, the only exception is
databases which must run 24/7, and Access isn't suitable as a back-end for
that anyway. SQL-Server has a built-in backup utility which works while the
database is in use.
 
J

John J.

I don't have schedule authority nor functionality at my disposal. With
outsourced IT, these simple solutions for an 'unsupported' app, aren't so
easy to achieve, I mean not technically but politically.
 
A

Arvin Meyer [MVP]

I would think that management would want to protect that data. I would also
think that any IT department, outsourced or not, would not like it known
that it blocked a reasonable backup schedule, especially if not doing so
endangers the business process. I know that IT admins can get very full of
themselves and behave like storm troopers, but not properly backing up is a
dangerous position to take.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top