Can anyone help me figure out why I continue to get a runtime error '3010' "TABLE qryMultiSelect ALREADY EXISTS'? Here is my code. thank you in advance for any help!!! -
Private Sub cmbSelectionDone_Click()
-
Dim db As DAO.Database
-
Dim qdf As DAO.QueryDef
-
Dim varItem As Variant
-
Dim strCriteria As String
-
Dim strSQL As String
-
-
Set db = CurrentDb()
-
Set qdf = db.QueryDefs("qryMultiSelect")
-
If Me!cboxRangeName = -1 Then
-
myPath = txtFilePath & txtFileName
-
myFileName = Me!txtFileName
-
DoCmd.SetWarnings (False)
-
DoCmd.RunSQL "DELETE * FROM TempSymbol"
-
DoCmd.SetWarnings (True)
-
DoCmd.TransferSpreadsheet acImport, , "TempSymbol", "" & myPath & "", True, "" & txtRangeName & ""
-
MsgBox "The symbols have been successfully imported."
-
strSQL = "SELECT DailyPrice.Symbol, DailyPrice.LocateDate, DailyPrice.MarketPrice, DailyPrice.PriceFlag " & _
-
"FROM TempSymbol, DailyPrice " & _
-
"WHERE (((DailyPrice.Symbol) = [TempSymbol]![Symbol])) " & _
-
"ORDER BY DailyPrice.Symbol, DailyPrice.LocateDate;"
-
qdf.SQL = strSQL
-
'check this out...maybe delete it later
-
qdf.Close
-
DoCmd.TransferSpreadsheet acExport, , "qryMultiSelect", "" & myPath & ""
-
MsgBox "The table have been successfully exported to " & myFileName & "."
-
Set db = Nothing
-
Set qdf = Nothing
-
Exit Sub
-
End If
-
'DoCmd.TransferSpreadsheet acExport, , "qryMultiSelect", "" & myPath & ""
-
-
If IsNull(txtGetList) Then
-
For Each varItem In Me!lstSelectSymbol.ItemsSelected
-
strCriteria = strCriteria & "'" & Me!lstSelectSymbol.ItemData(varItem) & "',"
-
Next varItem
-
-
If Len(strCriteria) = 0 Then
-
MsgBox "You did not select anything from the list", vbExclamation, "Nothing to find!"
-
Set db = Nothing
-
Set qdf = Nothing
-
Me!lstSelectSymbol.SetFocus
-
Exit Sub
-
End If
-
-
strCriteria = Left(strCriteria, Len(strCriteria) - 1)
-
myPath = txtFilePath & txtFileName
-
myFileName = Me!txtFileName
-
-
strSQL = "SELECT DailyPrice.Symbol, DailyPrice.LocateDate, DailyPrice.MarketPrice, DailyPrice.PriceFlag FROM DailyPrice " & _
-
"WHERE DailyPrice.Symbol IN (" & strCriteria & ") " & _
-
"ORDER BY DailyPrice.Symbol, DailyPrice.LocateDate;"
-
-
qdf.SQL = strSQL
-
DoCmd.TransferSpreadsheet acExport, , "qryMultiSelect", "" & myPath & ""
-
MsgBox "The table have been successfully exported to " & myFileName & "."
-
qdf.Close
-
Set db = Nothing
-
Set qdf = Nothing
-
Exit Sub
-
End If
-
strCriteria = Me!txtGetList
-
myPath = txtFilePath & txtFileName
-
myFileName = Me!txtFileName
-
-
' On Error GoTo Do_Nothing
-
-
strSQL = "SELECT DailyPrice.Symbol, DailyPrice.LocateDate, DailyPrice.MarketPrice, DailyPrice.PriceFlag FROM DailyPrice " & _
-
"WHERE DailyPrice.Symbol IN (" & strCriteria & ") " & _
-
"ORDER BY DailyPrice.Symbol, DailyPrice.LocateDate;"
-
-
qdf.SQL = strSQL
-
DoCmd.OpenQuery "qryMultiSelect"
-
DoCmd.TransferSpreadsheet acExport, , "qryMultiSelect", "" & myPath & ""
-
MsgBox "The table have been successfully exported to " & myFileName & "."
-
qdf.Close
-
Set db = Nothing
-
Set qdf = Nothing
-
-
End Sub
10 21461 MMcCarthy 14,534
Recognized Expert Moderator MVP
What line exactly is the code stopping at?
The error is occuring at the first instance of:
DoCmd.TransferS preadsheet acExport, , "qryMultiSelect ", "" & myPath & ""
MMcCarthy 14,534
Recognized Expert Moderator MVP
The error is occuring at the first instance of:
DoCmd.TransferS preadsheet acExport, , "qryMultiSelect ", "" & myPath & ""
Where are you exporting to?
Are you sending to another database?
MMcCarthy 14,534
Recognized Expert Moderator MVP
Although Access says Table already exists, it may be talking about the excel spreadsheet. If this is on a network you may be having problems overwriting it.
To test this theory
Change the path each time ( small change to the name would be enourgh) and see if you still get the error
NeoPa 32,567
Recognized Expert Moderator MVP
Good idea.
I make it a policy always to attempt deletion of any resulting file before writing it, using On Error & all that stuff where required. That way I can see if it's a file problem rather than code, and also I can re-run the code as many times as I need without worrying that it will only work the first time.
Funny - I researched the help file because at my company I wrote a bunch of code and ran into the same thing. That damn exportspreadshe et, or TransferSpreads heet commands - or actually the one I amworking with, TransferText - all say that if the file exists it will over-write the file. NOT TRUE! If the file exists, you get a trappable error.
My solution is if you get the error, trap for the bitch on a if Err.Number = 3010 then **** delete the fuc**ng file using 'Kill <path>' ****. HELP FILE IS WRONG - those command do NOT OVER-WRITE FILE IF IF EXISTS. They get an error.
Cheers.
Denburt 1,356
Recognized Expert Top Contributor
O.K. First she asked which line of code and you posted a line of code that is used three or more times in your routine.
I did notice this in your first if statement you appear to have as so and it looks fine: -
qdf.SQL = strSQL
-
'check this out...maybe delete it later
-
qdf.Close
-
DoCmd.TransferSpreadsheet acExport, , "qryMultiSelect", "" & myPath & ""
-
Then the following statements have it a little different which could and is probably why you are having this issue. I Transfer export spreadsheets and HTML all day long and it always overwrites the older one with no issues. -
-
qdf.SQL = strSQL
-
DoCmd.TransferSpreadsheet acExport, , "qryMultiSelect", "" & myPath & ""
-
MsgBox "The table have been successfully exported to " & myFileName & "."
-
qdf.Close
-
I would close that QDF before you try to transfer it or you will not get the results you are looking for since the new qdf has not been completed.
Since the original post is three years old, I'm going to go out on a limb and guess that he/she has moved on. Then again, they may work for the government...
Anyway, hopefully this will help somebody: The most likely explanation is that the output spreadsheet is open. If so, the easy fix is to simply close the spreadhseet, and re-run the code. If it's not such an obvious problem, it's probably similar; perhaps the sheet is in a read-only state for some reason, such as network permissions, e.g.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Rahul Bakshi |
last post by:
Hi
I am getting this error which is frustrating me a lot
Microsoft VBScript runtime error '800a01c9'
This key is already associated with an element of this collection
/process.asp, line 362
|
by: Neo |
last post by:
Hi, I have dumped a database into the file named dbase.sql
when I am trying to recreate the database its giving the following
error.
can any one help me in this regard?
# vim dbase.sql
# mysql -u "root" project < dbase.sql
ERROR 1050 at line 19: Table 'columns_priv' already exists
Vasundhar/
|
by: Abhi |
last post by:
FYI:
This message is for the benefit of MS Access Community. I found that
this prblem has been encounterd by many but there is hardly any place
where a complete solution is posted. So I thought I should give back
to the community by posting our findings.
Thanks you all for all your help till now by posting problems and
their solutions.
~Abhijit
|
by: RBohannon |
last post by:
I've developed a database in Access 2000 on Windows 2000. I have been
asked to put the database on a machine running Windows XP. I copied
the database onto the XP machine with some data already in it.
Everything seemed to be working correctly, until I tried to import new
data.
New data is imported into the database from a floppy disk. To prevent
duplicate entries, I have a boolean function called Exists which uses
the Seek method of...
|
by: tony dong |
last post by:
Hi there
I use vs.net 2005 with standard sql 2005 under machine\sql2005 for instant
when I create webpart, the code get from quickstart as follow:
<%@ Page Language="C#" %>
<%@ Register Src="WebPartPageMenu.ascx" TagName="WebPartPageMenu" TagPrefix="uc1" %>
<html>
<head id="Head1" runat="server">
<title>Web Part Page</title>
| |
by: delusion7 |
last post by:
Trying to create a table and insert records from a webform and I keep getting this message:
"Successfully created the registration table.
Unable to execute the query.
Error code 1050: Table 'registration' already exists"
Then after the table is created I re-run the query/webform and I don't receive the error message, but it doesn't update my table?
When I go to mySQL it shows the table 'registration' but has no updated...
|
by: g_man |
last post by:
I am trying trap Runtime error 3022 (duplicates) in the click event of
a command button that closes the form. I have code in the Form_Error
event that does a good job of providing a more meaningful error message
than the default. It works in every situation except when the user
clicks the close button. I am using Me.Dirty=False to force a save but
if there are duplicates I just get the standard Runtime 3022 error
message. I am wondering...
|
by: rn5a |
last post by:
During registration, users are supposed to enter the following
details: First Name, Last Name, EMail, UserName, Password, Confirm
Password, Address, City, State, Country, Zip & Phone Number. I am
using MS-Access 2000 database table for this app. Note that the
datatype of all the fields mentioned above are Text. Apart from the
above columns, there's another column in the DB table named
'RegDateTime' whose datatype is Date/Time which is...
|
by: towsie |
last post by:
Hi,
I am having a problem with code below, I am getting a runtime error 424: Object Required.
The section of code in bold is where the error occurs.
Any help would be greatly appreciated.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |