PC Review


Reply
Thread Tools Rate Thread

Deleting table in Access 2000

 
 
=?Utf-8?B?RGVs?=
Guest
Posts: n/a
 
      12th Apr 2006
My code creates a table for a report to use as its Record Source and I want
to delete the table when the report is closed. I have tried the following
code:

DoCmd.DeleteObject acTable, "My Table",

but I get an error stating that the database engine can not lock the table
because it is in use. When I try to remove the table as the report's Record
Source a message tells me that I can not set the Record Source after printing
has started, even if I'm not printing the report.

How can I delete this table?
--
Thank you,
Del
 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      12th Apr 2006
What event are you putting the code into?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Del" <(E-Mail Removed)> wrote in message
news:55FAAD4F-8483-4667-8336-(E-Mail Removed)...
> My code creates a table for a report to use as its Record Source and I
> want
> to delete the table when the report is closed. I have tried the following
> code:
>
> DoCmd.DeleteObject acTable, "My Table",
>
> but I get an error stating that the database engine can not lock the table
> because it is in use. When I try to remove the table as the report's
> Record
> Source a message tells me that I can not set the Record Source after
> printing
> has started, even if I'm not printing the report.
>
> How can I delete this table?
> --
> Thank you,
> Del



 
Reply With Quote
 
=?Utf-8?B?RGVs?=
Guest
Posts: n/a
 
      12th Apr 2006
I've put it on Report_Close() first and then tried it on Form_Current() event
of the form that would receive the focus once the report was closed.
--
Thank you,
Del


"Douglas J. Steele" wrote:

> What event are you putting the code into?
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Del" <(E-Mail Removed)> wrote in message
> news:55FAAD4F-8483-4667-8336-(E-Mail Removed)...
> > My code creates a table for a report to use as its Record Source and I
> > want
> > to delete the table when the report is closed. I have tried the following
> > code:
> >
> > DoCmd.DeleteObject acTable, "My Table",
> >
> > but I get an error stating that the database engine can not lock the table
> > because it is in use. When I try to remove the table as the report's
> > Record
> > Source a message tells me that I can not set the Record Source after
> > printing
> > has started, even if I'm not printing the report.
> >
> > How can I delete this table?
> > --
> > Thank you,
> > Del

>
>
>

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      13th Apr 2006
To remove it in the form, you'd have to open the report in design mode. That
may be your only alternative though.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Del" <(E-Mail Removed)> wrote in message
news:BBEECDD4-CF47-4DDC-9B8E-(E-Mail Removed)...
> I've put it on Report_Close() first and then tried it on Form_Current()
> event
> of the form that would receive the focus once the report was closed.
> --
> Thank you,
> Del
>
>
> "Douglas J. Steele" wrote:
>
>> What event are you putting the code into?
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no private e-mails, please)
>>
>>
>> "Del" <(E-Mail Removed)> wrote in message
>> news:55FAAD4F-8483-4667-8336-(E-Mail Removed)...
>> > My code creates a table for a report to use as its Record Source and I
>> > want
>> > to delete the table when the report is closed. I have tried the
>> > following
>> > code:
>> >
>> > DoCmd.DeleteObject acTable, "My Table",
>> >
>> > but I get an error stating that the database engine can not lock the
>> > table
>> > because it is in use. When I try to remove the table as the report's
>> > Record
>> > Source a message tells me that I can not set the Record Source after
>> > printing
>> > has started, even if I'm not printing the report.
>> >
>> > How can I delete this table?
>> > --
>> > Thank you,
>> > Del

>>
>>
>>



 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      13th Apr 2006
"Del" <(E-Mail Removed)> wrote in message
news:55FAAD4F-8483-4667-8336-(E-Mail Removed)
> My code creates a table for a report to use as its Record Source and
> I want to delete the table when the report is closed. I have tried
> the following code:
>
> DoCmd.DeleteObject acTable, "My Table",
>
> but I get an error stating that the database engine can not lock the
> table because it is in use. When I try to remove the table as the
> report's Record Source a message tells me that I can not set the
> Record Source after printing has started, even if I'm not printing
> the report.
>
> How can I delete this table?


If you're opening the report in preview, you could have your code loop
after opening the report, until the report is closed. Like this:

DoCmd.OpenReport "MyReport", acViewPreview

Do While CurrentProject.AllReports("MyReport").IsLoaded
DoEvents
Loop
DoCmd.DeleteObject acTable, "MyTable"

I'm not sure about a couple of things:

1. I don't know if this works for reports that are opened for
printing, rather than for preview.

2. I don't know whether you might have to first loop until the
report *is* loaded, and only then loop until it isn't.

But you can check those things out.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
=?Utf-8?B?RGVs?=
Guest
Posts: n/a
 
      13th Apr 2006
Thank you. I'll give this a try.
--
Thank you,
Del


"Dirk Goldgar" wrote:

> "Del" <(E-Mail Removed)> wrote in message
> news:55FAAD4F-8483-4667-8336-(E-Mail Removed)
> > My code creates a table for a report to use as its Record Source and
> > I want to delete the table when the report is closed. I have tried
> > the following code:
> >
> > DoCmd.DeleteObject acTable, "My Table",
> >
> > but I get an error stating that the database engine can not lock the
> > table because it is in use. When I try to remove the table as the
> > report's Record Source a message tells me that I can not set the
> > Record Source after printing has started, even if I'm not printing
> > the report.
> >
> > How can I delete this table?

>
> If you're opening the report in preview, you could have your code loop
> after opening the report, until the report is closed. Like this:
>
> DoCmd.OpenReport "MyReport", acViewPreview
>
> Do While CurrentProject.AllReports("MyReport").IsLoaded
> DoEvents
> Loop
> DoCmd.DeleteObject acTable, "MyTable"
>
> I'm not sure about a couple of things:
>
> 1. I don't know if this works for reports that are opened for
> printing, rather than for preview.
>
> 2. I don't know whether you might have to first loop until the
> report *is* loaded, and only then loop until it isn't.
>
> But you can check those things out.
>
> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com
>
> (please reply to the newsgroup)
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting a table in access Shanandoor Microsoft Access Getting Started 1 27th Jan 2008 09:49 PM
Deleting a table in access 2007 =?Utf-8?B?ZnJhbnRpY19naXJs?= Microsoft Access Database Table Design 5 18th Apr 2007 03:22 AM
Deleting records from a table in Access =?Utf-8?B?anNhbHZh?= Microsoft Access 3 30th Aug 2006 05:51 PM
Error Deleting Table from Access DB =?Utf-8?B?TWFyaw==?= Microsoft ASP .NET 1 20th Apr 2005 08:33 AM
Deleting An Access Table Charles Microsoft Excel Programming 1 8th Oct 2004 02:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:02 PM.