Solved

TransferText FileName - Setting from a textbox?

Posted on 2006-10-29
10
320 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
  • 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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.

776 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