Solved

TransferText FileName - Setting from a textbox?

Posted on 2006-10-29
10
316 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
Comment Utility
How are you defining strLongFileName?

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

Expert Comment

by:mbizup
Comment Utility
Putting it in context:

Dim strLongFileName As String

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

Author Comment

by:66tigger40
Comment Utility
Hi

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

Any ideas

Thanks
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:66tigger40
Comment Utility
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
Comment Utility
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
Comment Utility
Don't forget that you need the ENTIRE file location, including drive, folder location and file extention
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
66tigger40,

Do you still need help with this?
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now