PC Help Headquarters: Access VBA DoCmd.TransferSpreadsheet help - PC Help Headquarters

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Access VBA DoCmd.TransferSpreadsheet help

#1
User is offline   madmatt2006 

  • PC Guru 25 years in I.T
  • PipPipPip
  • Group: Members
  • Posts: 685
  • Joined: 24-August 09
Hi Members :D

Needed a little help on an access program I'm working on for PCHHQ it uses the DoCmd.TransferSpreadsheet to export or import data. It's run off a button on a form with this code

this is the export code it works
Private Sub Command0_Click()
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "Data Feed Query", "D:\ExportData.xls"
MsgBox ("Done!")
End Sub

this is the problem code for import
Private Sub Command2_Click()
DoCmd.TransferSpreadsheet acImportDelim, acSpreadsheetTypeExcel12, "Data Feed", "C:\DataFeed\Data Feed.txt", False
End Sub


I get this error
run time error 3274
I get an error "Run-time error '3274': External table isn't in the expected format" ...

I have saved the file that is getting imported as txt tab delimited. So I'm a little stuck any ideas?
0

#2
User is offline   Uncle Fester 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 120
  • Joined: 11-September 09
  • LocationEdinburgh, UK
I'll have a look at it tomorrow, must admit my first foray into VB was a front end for an Access db (a lending library) so do have some exp there. Will try to duplicate the error and see if can find a way thru. Bit late for me now -nearly 2 am and got work in am. See what I can do..

'Once I had a life, now I have a computer'
0

#3
User is offline   noop 

  • Administrator
  • View gallery
  • Group: Administrators
  • Posts: 3,223
  • Joined: 24-August 09
  • LocationUSA

View PostUncle Fester, on 17 September 2009 - 12:49 AM, said:

'Once I had a life, now I have a computer'


Lol, I sadly am in that same boat.

As for the problem. You need it to be an excel file, not text. Hence, .txt should be .xls :D
Posted Image Posted Image
0

#4
User is offline   Uncle Fester 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 120
  • Joined: 11-September 09
  • LocationEdinburgh, UK
Just a thought - can you send me examples of the exported file and the one to be imported. Use This Address as others often fill up with *stuff*, plus I get a lot of newsletters from MS and others - won't have to wade through looking for it. Never used 07 too, will install it tom on my programming PC.

Noop's point is a good one, bit late at night for me and should have noticed it. What you can do is convert the tab delimited file to a spreadsheet in code by importing to excel(will find you a snippet) before importing it
0

#5
User is offline   madmatt2006 

  • PC Guru 25 years in I.T
  • PipPipPip
  • Group: Members
  • Posts: 685
  • Joined: 24-August 09
Yay all working this code. I would have sent over Uncle Fester but too big :blink:

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "Data Feed", "C:\DataFeed\DataFeed.xls", True
MsgBox ("Done Importing!")

had error because file was not saved in proper format.
0

#6
User is offline   Uncle Fester 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 120
  • Joined: 11-September 09
  • LocationEdinburgh, UK
Bet you're a happy bunny now! Well done to noop for picking up on that, should have seen that too, too busy thinking about bed. Laters...
0

#7
User is offline   madmatt2006 

  • PC Guru 25 years in I.T
  • PipPipPip
  • Group: Members
  • Posts: 685
  • Joined: 24-August 09
Later my friend :D have a great sleep!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users