Solved

TransferText FileName - Setting from a textbox?

Posted on 2006-10-29
10
322 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

749 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