Solved

TransferText FileName - Setting from a textbox?

Posted on 2006-10-29
10
327 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

734 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