A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

SQL Code Problem



 
 
Thread Tools Display Modes
  #11  
Old April 8th, 2005, 12:45 PM
matt donker via AccessMonster.com
external usenet poster
 
Posts: n/a
Default

I have tried compacting and repairing database and this does not help at
all. The following in my ammended code. I run the code at the startup
screen once an employee card is swiped the number appears in the textbox
and then this code is part of the on update event. Now that i have
switched and moved the tooling part above the inventory part the inventory
query is now the problem, giving me the same error about the table being
locked. My OS is Windows 2000 service pack 4, I am running Microsoft
Access 2000 9.0.6926 SP-3. Not quite sure what the SR number is but thats
all the info i could find.


'Run Make Table Query
Dim db As Database
Set db = CurrentDb
db.Execute "SELECT * INTO [tblToolA] FROM [tblToolingTracker]
WHERE DatePart ('m', [Date]) =" & MonthNum
DBEngine.Idle dbRefreshCache

'Export table to an excel file
DoCmd.OutputTo acOutputTable, "tblToolA", acFormatXLS, "\\
tor-file-01\BusinessImprovement\AssemblySummer\mto08428\Com puter Inventory
Database- Active\ToolingArchives\" & MonthName & YearNum


'Delete Table
DoCmd.DeleteObject acTable, "tblToolA"

CurrentDb.TableDefs.Refresh

'Run SQL that copys inventory records from last month to
new table
DBEngine.Idle dbRefreshCache

DoCmd.SetWarnings False
Dim strOutputSQLI As String

strOutputSQLI = "Select * INTO tblIArch" _
& " FROM [tblInventoryTaken] " _
& " WHERE DatePart('m', [Date Taken]) =" & MonthNum

DoCmd.RunSQL strOutputSQLI


'Output the table to an excel file
DoCmd.OutputTo acOutputTable, "tblIArch", acFormatXLS, "\\
tor-file-01\BusinessImprovement\AssemblySummer\mto08428\Com puter Inventory
Database- Active\InventoryArchives\" & MonthName & YearNum

'Delete the table from the database
DoCmd.DeleteObject acTable, "tblIArch"

CurrentDb.TableDefs.Refresh

--
Message posted via http://www.accessmonster.com
  #12  
Old April 8th, 2005, 01:27 PM
Van T. Dinh
external usenet poster
 
Posts: n/a
Default

It looks like you OS / Access are patched OK.

Which line of the code errored out?

--
HTH
Van T. Dinh
MVP (Access)



"matt donker via AccessMonster.com" wrote in
message news:d9698240d417419eb0a61163c6125d70@AccessMonste r.com...
I have tried compacting and repairing database and this does not help at
all. The following in my ammended code. I run the code at the startup
screen once an employee card is swiped the number appears in the textbox
and then this code is part of the on update event. Now that i have
switched and moved the tooling part above the inventory part the inventory
query is now the problem, giving me the same error about the table being
locked. My OS is Windows 2000 service pack 4, I am running Microsoft
Access 2000 9.0.6926 SP-3. Not quite sure what the SR number is but thats
all the info i could find.


'Run Make Table Query
Dim db As Database
Set db = CurrentDb
db.Execute "SELECT * INTO [tblToolA] FROM

[tblToolingTracker]
WHERE DatePart ('m', [Date]) =" & MonthNum
DBEngine.Idle dbRefreshCache

'Export table to an excel file
DoCmd.OutputTo acOutputTable, "tblToolA", acFormatXLS, "\\
tor-file-01\BusinessImprovement\AssemblySummer\mto08428\Com puter Inventory
Database- Active\ToolingArchives\" & MonthName & YearNum


'Delete Table
DoCmd.DeleteObject acTable, "tblToolA"

CurrentDb.TableDefs.Refresh

'Run SQL that copys inventory records from last month to
new table
DBEngine.Idle dbRefreshCache

DoCmd.SetWarnings False
Dim strOutputSQLI As String

strOutputSQLI = "Select * INTO tblIArch" _
& " FROM [tblInventoryTaken] " _
& " WHERE DatePart('m', [Date Taken]) =" & MonthNum

DoCmd.RunSQL strOutputSQLI


'Output the table to an excel file
DoCmd.OutputTo acOutputTable, "tblIArch", acFormatXLS,

"\\
tor-file-01\BusinessImprovement\AssemblySummer\mto08428\Com puter Inventory
Database- Active\InventoryArchives\" & MonthName & YearNum

'Delete the table from the database
DoCmd.DeleteObject acTable, "tblIArch"

CurrentDb.TableDefs.Refresh

--
Message posted via http://www.accessmonster.com



  #13  
Old April 8th, 2005, 03:30 PM
matt donker via AccessMonster.com
external usenet poster
 
Posts: n/a
Default

DoCmd.Run SQL and i get two error message for it that are the same message,
just comes up twice.

--
Message posted via http://www.accessmonster.com
  #14  
Old April 8th, 2005, 03:58 PM
Van T. Dinh
external usenet poster
 
Posts: n/a
Default

Not sure why you get the same error message twice but did you make sure that
both Tables [tblToolA] and [tblIArch] have been deleted before running the
code?

Try changing the remaining RunSQL to Execute also. If you get error on the
RunSQL, that means that the amended part of the code (using Execute) is OK,
perhaps?

Try also adding:

DoEvents

after the Idle statement for both Execute statement.

--
HTH
Van T. Dinh
MVP (Access)


"matt donker via AccessMonster.com" wrote in
message news:14afc0b0fb2d41c48621a874de43c2ab@AccessMonste r.com...
DoCmd.Run SQL and i get two error message for it that are the same

message,
just comes up twice.

--
Message posted via http://www.accessmonster.com



  #15  
Old April 11th, 2005, 12:41 PM
matt donker via AccessMonster.com
external usenet poster
 
Posts: n/a
Default

I have as you can see made both into execute statements, changed the
position of the idle statements and i still get the same error. 3010 table
already exsists although it doesn't because i make sure everytime that the
table is delted and gone and restart access just to make double sure. The
statement that makes the table tbliarch is the one that recieves the error
any more help/tips would be great as this is driving me insane.

'Run Make Table Query
Dim db As Database
Set db = CurrentDb
db.Execute "SELECT * INTO [tblToolA] FROM [tblToolingTracker]
WHERE DatePart ('m', [Date]) =" & MonthNum
DBEngine.Idle dbRefreshCache
CurrentDb.TableDefs.Refresh
'Export table to an excel file
DoCmd.OutputTo acOutputTable, "tblToolA", acFormatXLS, "\\
tor-file-01\BusinessImprovement\AssemblySummer\mto08428\Com puter Inventory
Database- Active\ToolingArchives\" & MonthName & YearNum


'Delete Table
DoCmd.DeleteObject acTable, "tblToolA"



'Run SQL that copys inventory records from last month to
new table
Dim dbI As Database
Set dbI = CurrentDb
dbI.Execute "SELECT * INTO [tblIArch] FROM
[tblInventoryTaken] WHERE DatePart('m', [Date Taken]) =" & MonthNum
DBEngine.Idle dbRefreshCache
CurrentDb.TableDefs.Refresh
'Output the table to an excel file
DoCmd.OutputTo acOutputTable, "tblIArch", acFormatXLS, "\\
tor-file-01\BusinessImprovement\AssemblySummer\mto08428\Com puter Inventory
Database- Active\InventoryArchives\" & MonthName & YearNum

'Delete the table from the database
DoCmd.DeleteObject acTable, "tblIArch"

--
Message posted via http://www.accessmonster.com
  #16  
Old April 11th, 2005, 02:32 PM
matt donker via AccessMonster.com
external usenet poster
 
Posts: n/a
Default

I moved the enitire code to run off a command button. So once the user
swipes there card and clicks continue instead of after update event and it
all works no problem. I guess it just couldn't work off the after update
event. Makes no sense to me but whatever i got it working so i am happy.
Thanks for all the help guys.

--
Message posted via http://www.accessmonster.com
  #17  
Old April 11th, 2005, 02:37 PM
Van T. Dinh
external usenet poster
 
Posts: n/a
Default

Just to confirm: Did you delete *both* Tables [tblToolA] and [tblIArch]
before running the code?

You wrote in your post that you deleted the Table (note: singular noun) but
you need to delete *two* Tables before running the code.

--
HTH
Van T. Dinh
MVP (Access)


"matt donker via AccessMonster.com" wrote in
message news:c0b6f89066094c4c9f287417bbbdb2cd@AccessMonste r.com...
I have as you can see made both into execute statements, changed the
position of the idle statements and i still get the same error. 3010

table
already exsists although it doesn't because i make sure everytime that the
table is delted and gone and restart access just to make double sure. The
statement that makes the table tbliarch is the one that recieves the error
any more help/tips would be great as this is driving me insane.

'Run Make Table Query
Dim db As Database
Set db = CurrentDb
db.Execute "SELECT * INTO [tblToolA] FROM

[tblToolingTracker]
WHERE DatePart ('m', [Date]) =" & MonthNum
DBEngine.Idle dbRefreshCache
CurrentDb.TableDefs.Refresh
'Export table to an excel file
DoCmd.OutputTo acOutputTable, "tblToolA", acFormatXLS, "\\
tor-file-01\BusinessImprovement\AssemblySummer\mto08428\Com puter Inventory
Database- Active\ToolingArchives\" & MonthName & YearNum


'Delete Table
DoCmd.DeleteObject acTable, "tblToolA"



'Run SQL that copys inventory records from last month to
new table
Dim dbI As Database
Set dbI = CurrentDb
dbI.Execute "SELECT * INTO [tblIArch] FROM
[tblInventoryTaken] WHERE DatePart('m', [Date Taken]) =" & MonthNum
DBEngine.Idle dbRefreshCache
CurrentDb.TableDefs.Refresh
'Output the table to an excel file
DoCmd.OutputTo acOutputTable, "tblIArch", acFormatXLS,

"\\
tor-file-01\BusinessImprovement\AssemblySummer\mto08428\Com puter Inventory
Database- Active\InventoryArchives\" & MonthName & YearNum

'Delete the table from the database
DoCmd.DeleteObject acTable, "tblIArch"

--
Message posted via http://www.accessmonster.com



  #18  
Old April 11th, 2005, 02:45 PM
Van T. Dinh
external usenet poster
 
Posts: n/a
Default

(sorry, accidentally hit the Send key previously)

Just to confirm: Did you delete *both* Tables [tblToolA] and [tblIArch]
before running the code?

You wrote in your post that you deleted the Table (note: singular noun) but
you need to delete *two* Tables before running the code.

Try this bit of *dirty* code:

********
On Error Resume Next
DoCmd.DeleteObject acTable, "tblToolA"

'Run Make Table Query
Dim db As Database
Set db = CurrentDb

db.Execute "SELECT * INTO [tblToolA] FROM [tblToolingTracker]
WHERE DatePart ('m', [Date]) =" & MonthNum
DBEngine.Idle dbRefreshCache
CurrentDb.TableDefs.Refresh

'Export table to an excel file
DoCmd.OutputTo acOutputTable, "tblToolA", acFormatXLS, "\\
tor-file-01\BusinessImprovement\AssemblySummer\mto08428\Com puter Inventory
Database- Active\ToolingArchives\" & MonthName & YearNum


'Delete Tables
DoCmd.DeleteObject acTable, "tblToolA"
DoCmd.DeleteObject acTable, "tblIArch"
CurrentDb.TableDefs.Refresh

'Run SQL that copys inventory records from last month to new table
'Dim dbI As Database (Don't need this)
'Set dbI = CurrentDb (Don't need this)
db.Execute "SELECT * INTO [tblIArch] FROM
[tblInventoryTaken] WHERE DatePart('m', [Date Taken]) =" & MonthNum
DBEngine.Idle dbRefreshCache
CurrentDb.TableDefs.Refresh

'Output the table to an excel file
DoCmd.OutputTo acOutputTable, "tblIArch", acFormatXLS, "\\
tor-file-01\BusinessImprovement\AssemblySummer\mto08428\Com puter Inventory
Database- Active\InventoryArchives\" & MonthName & YearNum

'Delete the table from the database
DoCmd.DeleteObject acTable, "tblIArch"
********

Any similar error when you run the above code?

--
HTH
Van T. Dinh
MVP (Access)


"matt donker via AccessMonster.com" wrote in
message news:c0b6f89066094c4c9f287417bbbdb2cd@AccessMonste r.com...
I have as you can see made both into execute statements, changed the
position of the idle statements and i still get the same error. 3010

table
already exsists although it doesn't because i make sure everytime that the
table is delted and gone and restart access just to make double sure. The
statement that makes the table tbliarch is the one that recieves the error
any more help/tips would be great as this is driving me insane.

'Run Make Table Query
Dim db As Database
Set db = CurrentDb
db.Execute "SELECT * INTO [tblToolA] FROM

[tblToolingTracker]
WHERE DatePart ('m', [Date]) =" & MonthNum
DBEngine.Idle dbRefreshCache
CurrentDb.TableDefs.Refresh
'Export table to an excel file
DoCmd.OutputTo acOutputTable, "tblToolA", acFormatXLS, "\\
tor-file-01\BusinessImprovement\AssemblySummer\mto08428\Com puter Inventory
Database- Active\ToolingArchives\" & MonthName & YearNum


'Delete Table
DoCmd.DeleteObject acTable, "tblToolA"



'Run SQL that copys inventory records from last month to
new table
Dim dbI As Database
Set dbI = CurrentDb
dbI.Execute "SELECT * INTO [tblIArch] FROM
[tblInventoryTaken] WHERE DatePart('m', [Date Taken]) =" & MonthNum
DBEngine.Idle dbRefreshCache
CurrentDb.TableDefs.Refresh
'Output the table to an excel file
DoCmd.OutputTo acOutputTable, "tblIArch", acFormatXLS,

"\\
tor-file-01\BusinessImprovement\AssemblySummer\mto08428\Com puter Inventory
Database- Active\InventoryArchives\" & MonthName & YearNum

'Delete the table from the database
DoCmd.DeleteObject acTable, "tblIArch"

--
Message posted via http://www.accessmonster.com



 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieve ActionSettings via VB BmlKidd Powerpoint 6 March 30th, 2005 05:33 PM
0x80040109 error when sending from SSL SMTP krouse General Discussion 7 March 15th, 2005 01:55 AM
Executing 'Transform' SQL in VBA Leo General Discussion 20 October 28th, 2004 10:42 AM
Access and SQL AHopper General Discussion 26 August 3rd, 2004 07:01 PM
Function isn't available in expressions in query expression Reiner Harmgardt General Discussion 4 July 21st, 2004 09:30 AM


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


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.