473,471 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Docmd.Transferspreadsheet

23 New Member
I am trying to impot a excel file and replace with existing table in database.
Every time it import a extra automated field(F1),so it gives the error message:
"Field'F1' doesnot exost in destination table'table name'"
How can i impot my excel file into existing table,whose field names are same?And without autonum field?
The code i craft is:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdImport_click()
  2. Dim msg As String
  3. Dim button As Variant
  4. Dim title As String
  5. Dim response As Variant
  6.  
  7. msg = "Is the updated file Task Import placed in File path with 'file name.xls'?"
  8. button = vbYesNo + vbDefaultButton2
  9. title = "File Location Checkpoint"
  10.  
  11. response = MsgBox(msg, button, title)
  12. If response = vbYes Then
  13. 'Delete old records from tbltask
  14.    DoCmd.SetWarnings False
  15.    DoCmd.RunSQL "Delete [dbaseTable name].* from [dbaseTable name]"
  16.    DoCmd.SetWarnings True
  17. 'Import new records from Excel file into tblTask
  18.    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "dbaseTable name", "File path with 'file name.xls'"
  19.    DoCmd.OpenForm "Form1"
  20. End If
  21. End sub
  22.  
Thankful for helping always!
Mar 29 '12 #1
7 5106
NeoPa
32,556 Recognized Expert Moderator MVP
If the data in the spreadsheet doesn't match the layout of the table, then it's not going to work. Probably obvious, but you seemm to need to be told that so I have done so.

Either make sure the data layout is the same, or else import the data into a separate table (that does match the data obviously) and follow that with an Append query to move the matching part of the data across to your originally-intended table.
Mar 29 '12 #2
usha2
23 New Member
yes the layout of both excel file and access table are same.
But when it impoting ,it automatically create a autonumber field,which is not matched.
So should i create a table in database with F1 field?
It again shows the error msg" F2...in destinationn table"
or any way is there to replace a existing file with imported file.
Mar 29 '12 #3
NeoPa
32,556 Recognized Expert Moderator MVP
You say they're the same, yet Access says they're different. Whom do I believe?

Why not explain the exact layout for each and we'll see which of you is correct, and how to move on from there.
Mar 29 '12 #4
usha2
23 New Member
The existing table in data base has 4 field:
1A
2B
3C
4D
(This is the impoted excel file by using File->Import)
In this file i want to replace all my imported data of new excel file.
The new excel file has also same field name,same sequence,same data type.
only the thing is that,while it importing the new excel file,it join a autonumber field,with default naming"F1".
Which means now the layout of new excel file is different.
how can i got the solution of this autonumber field?
Mar 29 '12 #5
NeoPa
32,556 Recognized Expert Moderator MVP
That doesn't make sense. How can there be a new field in those circumstances? This is still a contradiction. Please explain the situation clearly and illustrate the data (as your explanation is so unreliable I need something to give me a clue as to what you really mean). I can't help with this as it stands.
Mar 29 '12 #6
usha2
23 New Member
The existed table has 4 fiels:
Name(text)'Two space before this string.
Fname(text)
Lname(text)
Email(text)
Excel file try to import has 4 column;(All in Sheet1)
Name(text)'In A1 ,Two space before this string.
Fname(text)'In B1
Lname(text)'In C1
Email(text)'In D1
executing my 1st posted code,the error msg comes"F1.."
Next i tried by changing in my code:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8 "dbaseTable name", "File path with 'file name.xls',"A1:D1000""
now error msg is:
"Field' Name' doesnot exist..."
Mar 29 '12 #7
NeoPa
32,556 Recognized Expert Moderator MVP
Still no example data, and I have no idea what you mean when you say :
"Name(text)'Two space before this string."

The explanation is more detailed certainly, but I see nothing here to explain why that behaviour might occur. ... which leads us neatly back to the missing example data which was requested, but still not included in your post.
Mar 30 '12 #8

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

Similar topics

2
by: mcnewsxp | last post by:
how can i specify a particular worksheet using the docmd transferspreadsheet? thanks, mcnewsxp
1
by: O'Donnell Tribunal | last post by:
Hello Everybody, I am using the TransferSpreadsheet method to import spreadsheets for processing. say my code looks like this: DoCmd.TransferSpreadsheet acImport, 0, _ "tbltempImport1", ""...
3
by: user_5701 | last post by:
Hello, I'm getting an error with a Docmd.Transferspreadsheet line of code: DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel2000, "tblTest", pathAndFilename, True The above line...
13
by: aleksandra_83 | last post by:
Hello, I have searched all over google groups and internet, but I have not found a solution to this problem that has worked. The solutions I found helped me single out the line that is causing...
4
by: Tom Louchbaum | last post by:
I try to use this command to import a spreadsheet "DoCmd.TransferSpreadsheet acImport, 8, tablename & " -tbl", DIR & "Book2.xls", True" and it errors out. If I try to import that same...
3
by: sranilp | last post by:
Hey All, Actually I need to export the data from Access to Excel particular spreadsheet(ie.Raw Data),so I was using Docmd.Transferspreadsheet but in this syntax where i can give the spreadsheet...
2
by: amir369 | last post by:
Hi All, I'm trying to import an Excel sheet, but with more the one rang, couse the columns aint sequence. for example: DoCmd.TransferSpreadsheet acImport, , "DailyRprzntvRpt", _ ...
5
by: jerelp | last post by:
I have a form with one button the code for that button is On Error Resume Next DoCmd.TransferSpreadsheet acImport, 8, "FuelConsumption NewData", Me.tb_FileName, 1, "sheet2$" On Error Resume...
4
by: blammo04 | last post by:
My problem is that Access freezes up whenever I try to use the docmd.transferspreadsheet method, I can use the docmd.outputto and it works fine but I need to be able to use the transferspreadsheet...
0
by: Van Fitz | last post by:
I am importing an excel worksheet into an existing access 2000 table using TransferSpreadsheet. Im using a timestamp field as well in this table. This is going well, however, once the data is...
0
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...
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...
1
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.