All of my reports in MS Access were suddenly deleted - ms-access

Okay, so I have a couple of hundred reports in my MS Access database (yes, it's a big project, and yes, we should switch to SQL Server). I was working on one of the reports yesterday and was suddenly disconnected from the network. I have been having a lot of network outages at work, and I think it has something to do with the sudden disappearance of all the reports. I have never had admin privileges to set up Backup and Restore on my machine, and have had to back up the database manually myself.
My most recent version is from a week ago, but I have done A LOT of work since then. My question is whether or not a sudden disconnection from the network (and, subsequently, the database I was working in), could have caused the deletion, and whether or not it is possible to restore the database without having Backup and Restore set up on my computer.
Please help.
Edit: My databases are in a front-end/back-end format. It was the front-end database (with the reports, queries, and forms) that crashed, but the only items that were deleted were the reports.

It your database was corrupted once, it's hard to tell if it's possible to restore your missing reports from it.
The only 100% safe way to restore your changes would be to have a recent backup from before the corruption happened.
But it's definitely possible that a network outage, while users accessed the database and you made changes in the reports at the same time, lead to corrupting the file.
I know that it doesn't help you right now, but here is some advice for the future:
You should think about splitting your Access database in a front-end (which contains forms, reports and code) and a back-end (which only contains tables).
The back-end will be located on a central machine, and each user will have his own copy of the front-end.
Of course splitting the database and ensuring that the front-ends are automatically updated on the user's machines will require some initial work, but you will gain two benefits from it:
When you work on the front-end, you are working on your local machine, so you are less affected by network outages.
The back-end is more unlikely to be corrupted. As you unfortunately experienced yourself, changing reports, forms and code in an Access database that's in production use at the same time can lead to issues.
Plus, even if you're not able to set up Backup and Restore on your computer, you should backup your work more often. I do this several times a day by just copying the Access database manually (you will do this automatically without thinking once you're used to it).
EDIT:
Okay, it wasn't really clear from the question that your database is split into front-end and back-end.
The network outage stuff made me think that you were editing the "one and only central database".
I don't remember that I ever experienced something like that by myself, so I can just guess what you could do now.
One thing that comes to my mind is that you could try to export your reports (given that you know their names) to text files with the undocumented SaveAsText and LoadFromText commands:
'save your report in a text file on your disk
Application.SaveAsText acReport, "YourReport", "c:\YourReport.txt"
'load your report from the text file in another Access database
Application.LoadFromText acReport, "YourReport", "c:\YourReport.txt"
But this is just an idea, so I don't know if this will work in your case.
Maybe the reports are still there (and just not shown for some reason), then it might work.
I'm sorry to say this again, but:
Honestly, I don't have a lot of experience in repairing corrupted databases (not Access, and neither SQL Server, for which I'm responsible at work!) because I try very hard to never come in a situation like yours by frequently taking backups. LOTS of them (I've been called "paranoid" by co-workers because of that).
EDIT 2:
I just read in your comment to phoog's answer that the corrupted database was on the network (i.e. you edited it while it was on the network).
Advice for the future:
Don't ever do this, for the reasons that phoog already mentioned in his answer. If the database is already split into front-end and back-end, make a copy of the front-end and edit it on your local machine to prevent such stuff from happening again.
Plus, if the front-end with the reports is used by several users, don't let them all work on the same file on the network (for the same reason).
It's incredibly easy to give each user his own copy, including auto-updating when there's a new version of the front-end.
You can read here how I'm doing this at work:
How to automatically update MS-Access 2007 application

Your question leaves open several important points:
How is your application set up?
Is the MDB containing the reports on your network?
Are the tables in the same file or another one?
If the tables are in another file, where is it located?
Access is notoriously susceptible to data loss and file corruption when network connectivity is spotty. See http://support.microsoft.com/kb/303528 (the section "Additional best practices for network environments") for more information.
The information in this article ("How to troubleshoot and to repair a damaged Access 2002 or later database" http://support.microsoft.com/kb/283849) may help
Any files that you have on the network should have been backed up by your network administrators, so ask them for the most recent backup before you lost your reports. With luck, this will be more recent than your own most recent backup.

Related

whats the best set-up for locations of front-end and back-end mdb files?

I have two mdb access files, one of them is front-end app and the other one is back-end.
They both resides in the same pc. My question is if I move out the front-end out of this location and copy it in client pcs for each pc connecting to the back-end db, how can it affect the bloating in the front-end and even the back-end mdb files?
My guess is that the bloating rate in the front-end should now be distributed over the client pcs' front-end files. But I am not sure if it can impact the back-end too.
Any help would be appreciated.
The back end needs to be somewhere everyone can access it. Front ends should be distributed to all users so as there aren't any read/write conflicts or corruption from multiple users using the same front end. This is the preferred method of distributing FE/BE Access systems.
How can it affect bloating? Well, for one, you'll have X more users inserting/updating/deleting data out of your database. So instead of your 20 records, it could become 1000 records because the Back End is now supporting multiple users. This is normal database file size increase.
Bloating
What causes it?
Temporary tables
Non-querydef SQL statements
Not closing Recordsets/QueryDef objects (Close them and set them = Nothing)
Images
Forms
Row Locking
(I'm sure there are other things.)
I believe over the years JET has tried to push some updates to stifle some of the issues surrounding what causes bloating, but it does still occur.
If your users will just be using forms/reports/etc.. I think you will be fine with C&R if the size becomes worrisome.
Here's Microsoft's attempt at explaining how to keep your Access DB working 'smoothly.' There's also decompiling/recompiling if you're experiencing some VBA errors or 'Out Of Memory' occurs.

Splitting MS Access Database - Front End Part Location

One of the best practices as specified by Microsoft for Access Development is splitting Access application into 2 parts; Front End that hold all the object except tables and the Back End that holds the tables.
The msdn page links there to the article Splitting Microsoft Access Databases to Improve Performance and Simplify Maintainability that describes the process in details.
It is recommended that in multi user environment the Back End is stored on the server/shared folder while the Front End is distributed to each user.
That implies that each time there are any changes made to the front end they need to be deployed to every user machine.
My question is:
Assuming that the users themselves do not have rights to modify the Front End part of the application what would be the drawbacks/dangers of leaving this on the server as well next to the Back End copy?
I can see the performance issues here, but are there any dangers here like possible corruptions etc?
Thank you
EDIT
Just to clarify, the scenario specified in question assumes one Front End stored on the server and shared by users.
I understand that the recommendation is to have FE deployed to each user machine, but my question is more about what are the dangers if that is not done.
E.g. when you are given an existing solution that uses the approach of both FE and BE on the server. Assuming the the performance is acceptable and the customer is reluctant to change the approach would you still push the change? And why exactly? For example the danger of possible data corruption would definitely be the strong enough argument, but is that the case?
It is a part of follow up of my previous question From SQL Server to MS Access 2007
The only drawback to leaving the individual user specific copies of the FE on the server is network performance. It won't make a difference as far as data corruption.
But you shouldn't share a FE between multiple users. This is prone to corruptions on the FE and other weirdness. Each user should get their own copy of the FE. Also you can't replace it with a new copy while users are using it.
A client was running for years with the FE on individual user folders on the file server but running msaccess.exe in a Citrix cluster. The IT staff didn't want to have anything updating the local hard drives of the Citrix cluster server systems.
As far as deploying the FE see the Auto FE Updater at my website. Huge changes coming in the next week to make it much, much easier for both initial server install and easier user initial install.
To keep the front-end on the server would more or less defeat the purpose of splitting the database. Putting the front-end on the desktop reduces network traffic since the application is not retrieved for each use, and allows the front end database to contain tables with data that is private to each user for storing settings or temporary data.
If you wish to avoid data corruption, it is important that each user should have their own copy of the front-end. Allen Browne offers more details on avoiding corruption in this article
There are a number of utilities available to update the front-end version on the desktop as required, or you can even write such a utility yourself.
I agree with the others. Keeping the fe on the server is not recommended. Just put a batch file on your server that does the push. When you have an update send a shortcut to the batch file via email. That is one of many solutions. Once you set it up it is not a problem.
Seth
As an Access 2007 Programmer using a Front End (FE) that is linked to a Back End (BE) database (a.k.a. Split Database) I have done both of the above. Sending an updated FE to users has other overhead, esp if third party controls or applications are used.
As for Citrix, back in Access 97 days, a Citrix manager was able to allow me to put one copy of the FE in a server file location. It would create a new instance for each user that logged in. We were able to use over 50 users with out any impacts. I must qualify this by saying the Access VBA code used efficient updates and transactions with roll-backs rather than just simple Select statements.
My problem today is Access 2007 running on a Citrix server (Windows 2003).
When I am the only person logged into Citrix, the application ( I picked a large complex report that creates a custom Excel spreadsheet via automation for the test) it runs within 1% as fast as running the FE from my XP workstation, and linking to the BE on the Citrix server hard drive.
But, when two or three people log into the Citrix Server, the same report takes three times as long. However, while two or three people are logged into Citrix, I can run my FE from my XP workstation and it runs exactly like the single-user on citrix.
A FE posted on a shared networked drive, shared by two or three users is NOT advised for this same reason. Access FE are not designed to be shared (* I will spare the details*). That is why people put a FE on each workstation and share one database (BE).
What I find lacking in Citrix is some good step-by-step "how-to" run Access FE on Citrix. Ideally, a single file could be posted. When a user loggs into Citrix, Citrix should make a copy of the FE and assign the resources (for Access) to that user's login.
I think this is exactly what MS Office does automatically or at least has instructions on how to do it.
If such a document exist, please post it. A programmer like myself would love to hand it to the Citrix Administrator. It would solve a lot of problems.

How to set up a development environment in MS Access

I have created an MS Access 2003 application, set up as a split front-end/back-end configuration, with a user group of about five people. The front end .mdb sits on a network file server, and it contains all the queries, forms, reports, and VBA code, plus links to all the tables in the back end .mdb and some links to ODBC data sources like an AS/400. The back end sits on the same network file server, and it just has the table data in it.
This was working well until I "went live" and my handful of users started coming up with enhancement requests, bug reports, etc. I have been rolling out new code by developing/testing in my own copy of the front-end .mdb in another network folder (which is linked to the same back-end .mdb), then posting my completed file in a "come-and-get-it" folder, alerting the users, and they go copy/paste the new front-end file to their own folders on the network. This way, each user can update their front end when they're at a 'stopping point' without having to boot everyone out at once.
I've found that when I'm developing now, sometimes Access becomes extremely slow. Like, when I am developing a form and attempt to click a drop-down on the properties box, the drop-down arrow will push in, but it will take a few seconds before the list of options appears. Or there's tons of lag in selecting & moving controls on a form. Or lots of keyboard lag.
Then, at other times, there's no lag at all.
I'm wondering if it's because I'm linked to the same back end as the other users. I did make a reasonable effort to set up the queries, forms, reports etc. with minimal record locking, if any at all, depending on the need. But I may have missed something, or perhaps there is some other performance issue I need to address.
But I'm wondering if there is an even better way for me to set up my own development back-end .mdb, so I can be testing my code on "safe" data instead of the same live data as the rest of the users. I'm afraid that it's only a matter of time before I corrupt some data, probably at the worst possible moment.
Obviously, I could just set up a separate back-end .mdb and manually reconfigure the table links in the front end every time, using the Linked Table Manager. But I'm hoping there is a more elegant solution than that.
And I'm wondering if there are any other performance issues I should be considering in this multi-user, split database configuration.
EDIT: I should have added that I'm stuck with MS Access (not MS-SQL or any other "real" back end); for more details see my comment to this post.
If all your users are sharing the front end, that's THE WRONG CONFIGURATION.
Each user should have an individual copy of the front end. Sharing a front end is guaranteed to lead to frequent corruption of the shared front end, as well as odd corruptions of forms and modules in the front end.
It's not clear to me how you could be developing in the same copy of the front end that the end users are using, since starting with A2000, that is prohibited (because of the "monolithic save model," where the entire VBA project is stored in a single BLOB field in a single record in one of the system tables).
I really don't think the problems are caused by using the production data (though it's likely not a good idea to develop against production data, as others have said). I think they are caused by poor coding practices and lack of maintainance of your front end code.
turn off COMPILE ON DEMAND in the VBE options.
make sure you require OPTION EXPLICIT.
compile your code frequently, after every few lines of code -- to make this easy, add the COMPILE button to your VBE toolbar (while I'm at it, I also add the CALL STACK button).
periodically make a backup of your front end and decompile and recompile the code. This is accomplished by launching Access with the /decompile switch, opening your front end, closing Access, opening your front end with Access (with the SHIFT key held down to bypass the startup code), then compacting the decompiled front end (with the SHIFT key held down), then compiling the whole project and compacting one last time. You should do this before any major code release.
A few other thoughts:
you don't say if it's a Windows server. Linux servers accessed over SAMBA have exhibited problems in the past (though some people swear by them and say they're vastly faster than Windows servers), and historically Novell servers have needed to have settings tweaked to enable Jet files to be reliably edited. There are also some settings (like OPLOCKS) that can be adjusted on a Windows server to make things work better.
store your Jet MDBs in shares with short paths. \Server\Data\MyProject\MyReallyLongFolderName\Access\Databases\ is going to be much slower reading data than \Server\Databases. This really makes a huge difference.
linked tables store metadata that can become outdated. There are two easy steps and one drastic one to be taken to fix it. First, compact the back end, and then compact the front end. That's the easy one. If that doesn't help, completely delete the links and recreate them from scratch.
you might also consider distributing an MDE to your end users instead of an MDB, as it cannot uncompile (which an MDB can).
see Tony Toews's Performance FAQ for other generalized performance information.
1) Relink Access tables from code
http://www.mvps.org/access/tables/tbl0009.htm
Once I'm ready to publish a new MDE to the users I relink the tables, make the MDE and copy the MDE to the server.
2) I specifically created the free Auto FE Updater utility so that I could make changes to the FE MDE as often as I wanted and be quite confident that the next time someone went to run the app that it would pull in the latest version. For more info on the errors or the Auto FE Updater utility see the free Auto FE Updater utility at http://www.granite.ab.ca/access/autofe.htm at my website to keep the FE on each PC up to date.
3) Now when working on site at a clients I make the updates to the table structure after hours when everyone is out of the system. See HOW TO: Detect User Idle Time or Inactivity in Access 2000 (Q210297) http://support.microsoft.com/?kbid=210297 ACC: How to Detect User Idle Time or Inactivity (Q128814) http://support.microsoft.com/?kbid=128814
However we found that the code which runs on the timer event must be disabled for the programmers. Otherwise weird things start happening when you're editing code.
Also print preview would sometimes not allow the users to run a menu item to export the report to Excel or others. So you had to right click on the Previewed report to get some type of internal focus back on the report so they could then export it. This was also helped by extending the timer to five minutes.
The downside to extending the timer to five minutes was if a person stays in the same form and at the same control for considerable parts of the day, ie someone doing the same inquiries, the routine didn't realize that they had actually done something. I'll be putting in some logic sometime to reset this timer whenever they do something in the program.
4) In reference to another person commenting about scripts and such to update the schema see Compare'Em http://home.gci.net/~mike-noel/CompareEM-LITE/CompareEM.htm. While it has its quirks it does create the VBA code to update tables, fields, indexes and relationships.
Use VBA to unlink and re-link your tables to the new target when switching from dev to prod. It's been to many years for me to remember the syntax--I just know the function was simple to write.
Or use MS-Access to talk to MS-Access through ODBC, or some other data connection that lives outside of the client mdb.
As with all file base databases, you will eventually run into problems with peak usage or when you go over a small magical number somewhere between 2 and 30.
Also, Access tends to corrupt frequently, so backup, compact and repair need to be done on an frequent basis. 3rd party tools used to exist to automate this task.
As far as performance goes, the data is being processed client side, so you might want to use something like netmeter to watch how much data is going over the wire. The same principle about indexing and avoiding table scans apply to file base dbs as well.
Many good suggestions from other people. Here's my 2 millicents worth. My backend data is on server accessed through a Drive mapping. In my case, the Y drive. Production users get the mapping through a login script using active directory. Then the following scenarios are easily done by batch file:
Develop against local computer by doing a subst command in a batch file
run reports against last nights data by pointing Y to the backup server (read only)
run reports against end of month data by pointing to the right directory
test against specialized scenarios by keeping a special directory
In my environment (average 5 simultaneous users, 1000's of rows, not 10,000's.) corruption has occurred, but it's rare and manageable. Only once in the last several years have we resorted to the previous days backup. We use SQL Server for our higher volume stuff, but it's not as convenient to develop against, probably because we don't have a SQL admin on site.
You might also find some of the answers to this question (how to extract schemas from access) to be useful as well. Once you've extracted a schema using one of the techniques that were suggested you gain a whole range of new options like the ability to use source control on the schemas, as well as being able to easily build "clean" testing environments.
Edit to respond to comment:
There's no easy way to source control an Access database in it's native format, but schema files are just text files like any other. Hence, you can check them in and out of the source control software of your choice for easy version control/rollbacks.
Or course, it relies on you having a series of scripts set up to re-build your database from the schema. Once you do, it's normally fairly trivial to create an option/alternative version that rebuilds it in a different location, allowing you to build test environments from any previous committed version of the schema. I hope that clarifies a bit!
If you want to update the back end MDB schema automatically when you release a new FE to the clients then see Compare'Em http://home.gci.net/~mike-noel/CompareEM-LITE/CompareEM.htm will happily generate the VBA code need to recreate an MDB. Or the code to create the differences between two MDBs so you can do a version upgrade of the already existing BE MDB. It's a bit quirky but works.
I use it all the time.
You need to understand that a shared mdb file for the data is not a robust solution. Microsoft would suggest that SQL Server or some other server based database would be a far better solution and would allow you to use the same access front end. The migration wizard would help you make the changeover if you wanted to go that way.
As another uses pointed out, corruption will occur. It is simply a question of how often, not if.
To understand the performance issues you need to understand that to the server the mdb file with the data in it is simply that, a file. Since no code runs on the server, the server does not understand transactions, record locking etc. It simply knows that there is a file that a bunch of people are trying to read and write simultaniously.
With a database system such as SQL Server, Oracle, DB2. MySQL etc. the database program runs on the server and looks to the server like a single program accessing the database file. It is the database program (running on the server) that handles record locking, transactions, concurrency, logging, data backup/recovery and all the other nice things one wants from a database.
Since a database program designed to run on the server is designed to do that and only that, it can do it far better and more efficently that a program like Access reading an writing a shared file (mdb).
There are two rules for developing against live data
The first rule is . . . never develop
against live data. Not ever.
The second rule is . . .never develop
against live data. Not ever.
You can programatically change the bindings for linked tables, so you can write a macro to change your links when you're deploying a new version.
The application is slow because it's MS Access, and it doesn't like many concurrent users (where many is any number > 1).

How to deploy multiuser ms access 2007 DB

I've created a database in access 2007 that needs to be used by 3 users. I'm stuck because I don't know whether to place a copy on each users' computer or to place it on their SQL server. Placing it on the server would mean one access point which is desirable for data consistency but I don't know whether I need ActiveX. Don't know how to use it either. If I place it one each computer how do I work around the master file updates? Can somebody please break it all down, I'm a NEWBIE!!
Your question seems rather confused to me. You mention a SQL Server, but you don't say your application uses SQL Server for its data storage.
Thus, I can only assume that you have a single MDB or ACCDB file with your data tables and forms and reports all in the one file.
The only proper way to distribute this app is:
split it into front end (forms/reports/etc.) with linked tables that point to the back end (data tables only).
place the back end on your file server and relink your tables to point to the new location of the back end.
give a copy of the front end to each of the 3 users, who will run it from their desktop computers. If you're concerned about distributing changes to the front end, something like Tony Toews's front-end updater is very useful.
Others have jumped in to say that you should put the data in SQL Server, but most 3-user Access apps don't need the power of SQL Server. If you're not given administrative permissions on your SQL Server, it could be quite difficult to continue to alter your application's database.
On the other hand, if your database is going to grow to 1GB or more, or if you have strict security requirements, or if the data in your database is so important as to need completely failproof backups, then SQL Server would be a reasonable data store.
For most homegrown apps, not so much.
The "best" way I've worked this out is using Linked Tables in Access to go to SQL Server (since you stated you have that..?).
Using access as a front end in this scenario isn't the best thing you can do, but with 2007, it's a bit better than if you were a few versions back. Check out this article for info on linking Access into SqlServer:
Import or link to SQL Server data
One easy way is to use the EQL Data plugin: http://eqldata.com
That way you can give a copy of the database to each user, but users can sync the database with other users whenever they want. You can also access your tables and queries on the web.

How can I open an Access DB via ADO so that I can write, but others can only read?

From the documentation, I would expect adModeShareDenyWrite to be the way, but it's not working right.
I'm using an Access database via ADO. My connection string says Mode=8, which is adModeShareDenyWrite. But when I try to delete a row from a table, I get:
Unspecified error, Description:Could not delete from specified tables., Source:Microsoft JET Database Engine
In other words, the setting is preventing ME from updating the database using my OWN connection.
I found a couple other posts on the web reporting the same thing, the adModeShareDenyWrite setting used with Access not working as documented.
I am looking for a solution that doesn't involve an administrator changing permissions. It needs to be something that my program can control.
My motivation here is to minimize the chances of database corruption. One of the causes of mdb file corruption documented by Microsoft is two apps writing to the same db. So, I want to make sure that only one app can have a write connection to the db. Others can read, but should fail when they try to write. Whoever makes a connection first wins.
Cory Trager wrote:
My motivation here is to minimize the
chances of database corruption. One of
the causes of mdb file corruption
documented by Microsoft is two apps
writing to the same db. So, I want to
make sure that only one app can have a
write connection to the db. Others can
read, but should fail when they try to
write. Whoever makes a connection
first wins.
Why are you worrying about it? Jet is by default a multi-user database engine. If somebody else is updating a table, the data pages involved will be locked as read-only (in the state they were before the write began).
There is no realistic reason to fear corruption from mere multi-user interaction. Corruption of Jet databases usually happens because of dropped connections or an interruption of the connection during a write (such as users who force quit an app that is not responding as fast as they want).
I think your fear of corruption is misplaced.
On the other hand, you should still be able to open with an exclusive lock, and I'm not sure why it's not working. Have you considered using DAO instead of ADO to manipulate Jet data? Given that it's the native data interface (instead of a generic interface layer), it ought to be easier.
One solution is to give them access to a copy of the database. They can change whatever they want, but it won't keep past your copying it over with the master.
I suppose you access here an MDB file from a client interface, whatever it is, and others can also connect to the same file at the same time. When you use adModeShareDenyWrite in your connection mode, it means that you can still share the data with others (no locks of any kind on tables or records in the MDB file) but it can't be modified (this is why you get an error).
One solution would be to manage your connection parameters, with something like that:
(where you have a user object with a '.role' property, or anything equivalent ...)
if activeUser.role = "admin" then
m_connectionMode = adModeWrite
else
m_connectionMode = adModeShareDenyWrite
endif
Then you can open your ADO connection with the parameter m_connectionMode. Administrators will be given the right to insert/update/delete while other users will ony be able to view the data. This means you have somewhere in your program, or ideally in a table, some data saying who is what in your application.
EDIT: Following multiples comments with Corey:
You won't be able to do what you want to do in a straight way. My proposal: when the app accesses the database, it checks for a special file in the .mdb folder (whatever the file is).
If this file exists, the app opens a "read-only" connection.
If this file does not exist, the app creates the file (you can create one for example with "transferDatabase") and open a read-write connection. Once you quit the app, destroy the file.
If you have multiple users connecting to an access database across a network you might want to consider upgrading to SqlServer instead of using Access.
Corey Trager wrote:
I am looking for a solution that
doesn't involve an administrator
changing permissions. It needs to be
something that my program can control.
Well, if the problem is due to NTFS permissions being read-only for the user, there isn't a thing you can do to make the MDB writable. You don't specify where the MDB is stored, on a server or on a local hard drive, but in either case, for a user to have WRITE permissions on the MDB, NTFS permissions have to be set to allow it (for a share on a server, it has to be allowed both on the SHARE and on the underlying file). If it's a local file, the best solution is to make sure that you're storing the file in a location in which user-level logons have full WRITE permission. This would be anywhere in the user profile, and just about nowhere else.
That said, I'm not really suggesting that this is the source of your problem (I really can't say one way or the other), just pointing out that if it is the cause, then there's not a damned thing you can do programmatically to work around it.