本文介绍了VBA for File Import错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!

我是VBA和Access 2016的新手。我是一个SQL开发人员:)

I'm new to VBA and Access 2016 in general. I'm a SQL Dev :)

我正在努力帮助一个朋友。所以我来找专家!我正在尝试从.txt文件(总是一个不同的名称)导入数据,使用文件浏览器选择文件,使用DoCmd导入数据。一切都很好,直到实际的文件选择
,我选择文件后得到运行时错误3011。该文件位于本地文件夹中,因此我知道它在那里,我甚至可以在记事本中打开它并使用Access Text Import手动导入。我很确定这与将文件名传递给DoCmd有关。
感谢所有和所有帮助!



这是我的代码:

I'm trying to help out a friend. So I've come to the experts! I'm trying to import data from .txt files (always a diferent name) using the a File Browser to select the file and DoCmd to import the data. Everything goes fine up to the actual file selection and I get a run-time error 3011 after I select the file. The file is in a local folder so I know its there and I can even open it in Notepad and do an Import using Access Text Import manually. I'm pretty sure this has to do with pass the file name to DoCmd. Any and all help is appreciated!

Here is my code:

推荐答案

如果发生了什么?您更改以下行:

What happens if you change the following line from:

fileName:= varFile,_

fileName:=varFile, _

到此?

fileName :=。SelectedItems(1)

fileName:=.SelectedItems(1)

只是想一想......

Just a thought...


这篇关于VBA for File Import错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 04:25