473,386 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Error deleting a closed object in Access 2002

All,

I'm not sure how to adequately explain my problem in two sentences or less, so at the risk of providing TMI, here's the condensed verion.

I have developed an Access 2002 database file that contains a form, multiple queries and multiple reports. The purpose of the form is to allow the user to run various queries against my company's Sybase server and display a report.

Since the queries return ADO recordsets from the Sybase server, I've found it MUCH easier to write VB code that creates a table in Access based on the fields and data in the ADO recordset. I then use the table as the record source for my reports.

Each time a query is run, the old tables are deleted and then recreated with the new data from the Sybase server before the report is displayed.

I have many people in my company that like the using the form and reports in my database. But since the users of the database are constantly deleting and recreating tables, each user must have their own copy of the database file to avoid stepping on each other.

I continually get requests from users to modify and/or add new queries and reports. But since all of the users have their own copy of the database, distributing updated forms, queries and reports is a challenge.

I hit upon the idea of creating a table in the database that contains the names, types, and revision dates of all database objects (i.e. all queries, forms, reports, macros, modules, etc.). Then I placed a master copy of the database file on my companies network with the latest and greatest version of all database objects.

Finally, I added an "Update" button to the main form in the database. When the user clicks the button, a macro is launched. The macro runs a procedure that first closes the main form, then compares the revision date table in the master database file (on the company network) with the revision date table in the users local copy of the database.

If the revision date for a particular object is newer in the master database, the object is deleted from the user's local copy and the updated version of the object is copied in from the master database.

Make sense?

Everything work beautifully until today when I made a revision to the main form. Now when the "Update" button is clicked, the macro fires, the procedure is run, the main form is closed, but when the procedure tries to delete the main form object, Access gives me an error. The error says:

Run-time error '2008':
You can't delete the database object [
main form name] while it's open.

What gives? My procudre has already closed the form and it is no longer visible on the screen. Why does Access still think it's open?

I figure the problem has something to do with the fact that the form I'm trying to delete is the same form that called the macro which called the procedure that's trying to delete it.

Any thoughts on how I can get the form to completely close so I can delete it?

Here's the code I use to close the main form (called "PROGMAN_frm")
Expand|Select|Wrap|Line Numbers
  1. If CurrentProject.AllForms![PROGMAN_frm].IsLoaded Then
  2.     DoCmd.Close acForm, "PROGMAN_frm", acSaveNo
  3. End If
Thanks for your help and reading this lengthy post.

Scott
Jan 15 '08 #1
1 3163
jaxjagfan
254 Expert 100+
Are you trying to delete a form in a multiuser environment? If more than one user is in the database with the "Main" form open - it cannot be deleted until they exit the database. If all users are clear - try closing the mdb and reopening - it may be the .ldb file thats locking the form.

I had a multi-user reporting db that served a similar purpose as yours. The back-end databases (Oracle and DB2) were queried once per day and loaded the Access tables (loaded 20-30k records per day and only had the past 18 months of data in the Access tables). Once loaded an automated email when out an let the end-user group know it was available for download.

The load process was done early in the morning. Most of the end-users didn't have access to the Oracle or DB2 tables (no drivers to set-up or admin issues for Oracle or DB2).

Additional reports were added as requested and were available via a reports form to the end-user. Each time a report was added or something changed - the version # changed (MyAccessApp v5.012). A version report was also available within the app.
Jan 15 '08 #2

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

Similar topics

6
by: Matthew Louden | last post by:
The following ASP code yields the following error, but actually the new record is stored in database. The same error happens when the application deletes a record, such as sqlStmt ="delete from...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
7
by: Bob Darlington | last post by:
I'm using Access 2002 to try to open Outlook 2002 (late binding) using: Dim objOutlook As Object Set objOutlook = CreateObject("Outlook.Application") I get the above error if Outlook is closed...
1
by: iam247 | last post by:
Hi I am a relative beginner with SQL and ASP. With some help after previous posts I have a page which successfully requests querystrings from another page and deletes a record from an access...
6
by: Joachim | last post by:
I made some project changes (which seems it doesn't help if I undo) which have created compilation error: " Server Error in '/PCSWebApp1' Application....
8
by: Razak | last post by:
Hi, I have a class which basically do Impersonation in my web application. From MS KB sample:- ++++++++++++++++++++code starts Dim impersonationContext As...
0
by: Yelena Varshal via AccessMonster.com | last post by:
Hello We have a shortcut for our MS ACCESS application that uses a /Runtime switch because we may have some users that use Runtime. The application worked fine in Access 2000 and was tested with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.