Link to home
Start Free TrialLog in
Avatar of 66tigger40
66tigger40

asked on

TransferText FileName - Setting from a textbox?

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
Avatar of mbizup
mbizup
Flag of Kazakhstan image

How are you defining strLongFileName?

If that is typed into your textbox, try this:
strLongFileName=Me.TxtProfile
Putting it in context:

Dim strLongFileName As String

strLongFileName=Me.TxtProfile
DoCmd.TransferText acImportDelim, , "tblImport", strLongFileName, False
Avatar of 66tigger40
66tigger40

ASKER

Hi

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

Any ideas

Thanks
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?
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
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
66tigger40,

Do you still need help with this?