PC Review


Reply
Thread Tools Rate Thread

Docmd.openquery causes error

 
 
dkschoonover
Guest
Posts: n/a
 
      25th Feb 2009
I have a Make-Table Query "Repair"

When I double click the query to run it, it creates the table appropriately.

When I add it to a command button, it causes an error:
The database engine could not lock table "repairx" because it is already in
use by another person or process."

There is no one else in my test environment.

My code string looks like:
DoCmd.Close
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.OpenQuery stDocName2, acNormal, acEdit
DoCmd.OpenQuery StDocName3, acNormal, acEdit
DoCmd.OpenQuery StDocName4, acNormal, acEdit
DoCmd.RunMacro "Google Earth Export"
DoCmd.OpenQuery StDocName6, acNormal, acEdit
DoCmd.RunMacro "VSAT Validation Export"
=> DoCmd.OpenQuery "Repair", acViewNormal, acAdd
MsgBox ("Updates Complete")
DoCmd.OpenForm stDocName9, , , stLinkCriteria

I have tried it as acAdd and acEdit.

Any ideas?
 
Reply With Quote
 
 
 
 
Ken Snell \(MVP\)
Guest
Posts: n/a
 
      26th Feb 2009
Is the form that has the command button a form that is bound to the Repair
table? If yes, that is where the locking is coming from. Check this setting
in Record Locks property for the form and be sure that it's set to No Locks.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


"dkschoonover" <(E-Mail Removed)> wrote in message
news:27174F29-AD86-4242-8E1F-(E-Mail Removed)...
>I have a Make-Table Query "Repair"
>
> When I double click the query to run it, it creates the table
> appropriately.
>
> When I add it to a command button, it causes an error:
> The database engine could not lock table "repairx" because it is already
> in
> use by another person or process."
>
> There is no one else in my test environment.
>
> My code string looks like:
> DoCmd.Close
> DoCmd.OpenQuery stDocName, acNormal, acEdit
> DoCmd.OpenQuery stDocName2, acNormal, acEdit
> DoCmd.OpenQuery StDocName3, acNormal, acEdit
> DoCmd.OpenQuery StDocName4, acNormal, acEdit
> DoCmd.RunMacro "Google Earth Export"
> DoCmd.OpenQuery StDocName6, acNormal, acEdit
> DoCmd.RunMacro "VSAT Validation Export"
> => DoCmd.OpenQuery "Repair", acViewNormal, acAdd
> MsgBox ("Updates Complete")
> DoCmd.OpenForm stDocName9, , , stLinkCriteria
>
> I have tried it as acAdd and acEdit.
>
> Any ideas?



 
Reply With Quote
 
dkschoonover
Guest
Posts: n/a
 
      26th Feb 2009
The DoCmd.Close is closing the form before the queries run, so the only thing
open is the database window (showing the list of tables, etc.).

I checked the form which contains the command button, and all of the
subforms; they are all marked "No Locks"

Darryl

"Ken Snell (MVP)" wrote:

> Is the form that has the command button a form that is bound to the Repair
> table? If yes, that is where the locking is coming from. Check this setting
> in Record Locks property for the form and be sure that it's set to No Locks.
>
> --
>
> Ken Snell
> <MS ACCESS MVP>
> http://www.accessmvp.com/KDSnell/
>
>
> "dkschoonover" <(E-Mail Removed)> wrote in message
> news:27174F29-AD86-4242-8E1F-(E-Mail Removed)...
> >I have a Make-Table Query "Repair"
> >
> > When I double click the query to run it, it creates the table
> > appropriately.
> >
> > When I add it to a command button, it causes an error:
> > The database engine could not lock table "repairx" because it is already
> > in
> > use by another person or process."
> >
> > There is no one else in my test environment.
> >
> > My code string looks like:
> > DoCmd.Close
> > DoCmd.OpenQuery stDocName, acNormal, acEdit
> > DoCmd.OpenQuery stDocName2, acNormal, acEdit
> > DoCmd.OpenQuery StDocName3, acNormal, acEdit
> > DoCmd.OpenQuery StDocName4, acNormal, acEdit
> > DoCmd.RunMacro "Google Earth Export"
> > DoCmd.OpenQuery StDocName6, acNormal, acEdit
> > DoCmd.RunMacro "VSAT Validation Export"
> > => DoCmd.OpenQuery "Repair", acViewNormal, acAdd
> > MsgBox ("Updates Complete")
> > DoCmd.OpenForm stDocName9, , , stLinkCriteria
> >
> > I have tried it as acAdd and acEdit.
> >
> > Any ideas?

>
>
>

 
Reply With Quote
 
dkschoonover
Guest
Posts: n/a
 
      26th Feb 2009
Solved it - the issue was because the Query and the Table had the same name -
the Query didn't know what to do!!

"dkschoonover" wrote:

> The DoCmd.Close is closing the form before the queries run, so the only thing
> open is the database window (showing the list of tables, etc.).
>
> I checked the form which contains the command button, and all of the
> subforms; they are all marked "No Locks"
>
> Darryl
>
> "Ken Snell (MVP)" wrote:
>
> > Is the form that has the command button a form that is bound to the Repair
> > table? If yes, that is where the locking is coming from. Check this setting
> > in Record Locks property for the form and be sure that it's set to No Locks.
> >
> > --
> >
> > Ken Snell
> > <MS ACCESS MVP>
> > http://www.accessmvp.com/KDSnell/
> >
> >
> > "dkschoonover" <(E-Mail Removed)> wrote in message
> > news:27174F29-AD86-4242-8E1F-(E-Mail Removed)...
> > >I have a Make-Table Query "Repair"
> > >
> > > When I double click the query to run it, it creates the table
> > > appropriately.
> > >
> > > When I add it to a command button, it causes an error:
> > > The database engine could not lock table "repairx" because it is already
> > > in
> > > use by another person or process."
> > >
> > > There is no one else in my test environment.
> > >
> > > My code string looks like:
> > > DoCmd.Close
> > > DoCmd.OpenQuery stDocName, acNormal, acEdit
> > > DoCmd.OpenQuery stDocName2, acNormal, acEdit
> > > DoCmd.OpenQuery StDocName3, acNormal, acEdit
> > > DoCmd.OpenQuery StDocName4, acNormal, acEdit
> > > DoCmd.RunMacro "Google Earth Export"
> > > DoCmd.OpenQuery StDocName6, acNormal, acEdit
> > > DoCmd.RunMacro "VSAT Validation Export"
> > > => DoCmd.OpenQuery "Repair", acViewNormal, acAdd
> > > MsgBox ("Updates Complete")
> > > DoCmd.OpenForm stDocName9, , , stLinkCriteria
> > >
> > > I have tried it as acAdd and acEdit.
> > >
> > > Any ideas?

> >
> >
> >

 
Reply With Quote
 
Ken Snell \(MVP\)
Guest
Posts: n/a
 
      1st Mar 2009
It's unfortunate that ACCESS lets you name a table and a query with the same
name. That does cause confusion, as you've found. Good practice to ensure
that each object in your database has a unique name.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


"dkschoonover" <(E-Mail Removed)> wrote in message
news:FED8C455-DF70-4E03-8E80-(E-Mail Removed)...
> Solved it - the issue was because the Query and the Table had the same
> name -
> the Query didn't know what to do!!



 
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
What Do You Use Instead of DoCmd.OpenQuery or DoCmd.RunSQL Mr. JYC Microsoft Access VBA Modules 2 30th Sep 2008 07:31 PM
Property not found error while DoCmd.OpenQuery Ilya Microsoft Access Queries 3 26th Nov 2007 07:32 AM
Command text was not set for the command object error And DoCmd.OpenQuery tina Microsoft Access 1 23rd Jan 2004 08:29 PM
Command text was not set for the command object error And DoCmd.OpenQuery tina Microsoft Access Getting Started 1 23rd Jan 2004 08:29 PM
docmd.openquery jmonty Microsoft Access Forms 0 25th Sep 2003 04:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:52 PM.