Solved

TransferText FileName - Setting from a textbox?

Posted on 2006-10-29
10
328 Views
Last Modified: 2011-10-03
Hi All

I have a unbound text box that holds the full path of a file I want to include in my transfertext  - I've tried the following code, but it still tells me that I need a filename?

Dim strLongFileName As String

Me.TxtProfile.Value = strLongFileName
DoCmd.TransferText acImportDelim, , "tblImport", strLongFileName, False

What have i missed out?

Thanks in advance
0
Comment
Question by:66tigger40
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
10 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 17828909
How are you defining strLongFileName?

If that is typed into your textbox, try this:
strLongFileName=Me.TxtProfile
0
 
LVL 61

Expert Comment

by:mbizup
ID: 17828913
Putting it in context:

Dim strLongFileName As String

strLongFileName=Me.TxtProfile
DoCmd.TransferText acImportDelim, , "tblImport", strLongFileName, False
0
 

Author Comment

by:66tigger40
ID: 17828989
Hi

I've tried this and I get an error message saying I can't import this file?

Any ideas

Thanks
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 61

Expert Comment

by:mbizup
ID: 17829000
Try putting in a messagebox statement:

Dim strLongFileName As String

strLongFileName=Me.TxtProfile
msgBox strLongFileName
DoCmd.TransferText acImportDelim, , "tblImport", strLongFileName, False

Does the message box show the file name correctly?  Also verify that the file exists exactly as specified.

Beyond that, What is the exact error number/message?
0
 

Author Comment

by:66tigger40
ID: 17829004
Hi

Yes the file name is correct

The message I'm now getting is the following:

Runtime 2391
Field F1 Doesnt exist in destination table 'tblImport'

Thanks for all your help so far
0
 
LVL 61

Accepted Solution

by:
mbizup earned 250 total points
ID: 17829059
Try this approach:

From AccessToolbar,

File -> Get External Data

Select the file you are trying to import.  If this is a one-time deal, you can follow the prompts to import the file into a table.  Otherwise, you can click on the "Advanced button", and define an import specification to pull in your data with the column names you choose, then save the import specification for later use.  You would modify your code like this to use the specification:

Dim strLongFileName As String

strLongFileName=Me.TxtProfile
msgBox strLongFileName
DoCmd.TransferText acImportDelim,"YourImportSpecificationName" , "tblImport", strLongFileName, False
                                                             ^-----Add this, using the name you saved your specification with

Give that a try...  I need to go out for a few hours, and will check in later...
0
 
LVL 26

Assisted Solution

by:dannywareham
dannywareham earned 250 total points
ID: 17829063
Don't forget that you need the ENTIRE file location, including drive, folder location and file extention
0
 
LVL 61

Expert Comment

by:mbizup
ID: 17830176
66tigger40,

Do you still need help with this?
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question