从命令行向MS Access表添加记录 [英] Adding records to MS Access table from command line

查看:140
本文介绍了从命令行向MS Access表添加记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的文本文件是用逗号分隔的记录创建的。我试图弄清楚如何构建一个将记录导入MSA表的命令行方法。最终结果是我可以右键单击.txt文件,在上下文菜单上会有一个选项,上面写着将记录添加到''模块''表中,这将显示一个命令将执行导入命令的窗口。我对上下文菜单(和使用注册表)没有任何问题,但我对宏并不是很熟悉,具体来说 - 我如何将文件名从命令行传输到MSA中的宏?有人会知道更好的方法吗?

解决方案

我不确定如何做到这一点,但你不能只是从访问中打开文件浏览器然后选择要导入的文件?或创建一个显示目录结构的表单,带有导入按钮?


文本文件由另一个程序生成,并且它们不断被创建。我希望能够从文本文件中添加记录而无需手动打开MS Access。


我想我有一个解决方案,但它有点混乱,并且它只适用于每次传入文件放入同一文件夹时


使用批处理文件将传入目录中的所有文件重命名为标准格式。


使用相同的批处理文件打开一个访问数据库,在该数据库中,您已将启动(在工具下)设置为具有单个字段的表单,该字段在Gotfocus上设置为运行宏。 (我有点新访问,我不确定是否有另一种方法可以在启动时运行宏。)

在宏中使用Transfertext操作并在设置中使用Import将文件名分隔并设置为使用批处理文件设置的标准化文件名。

如果只想导入数据,则将带有Exit的Runcommand操作添加为宏命令没有别的。


您现在可以手动将导入的文件移动到存档文件夹,或者在批处理文件中添加一行来执行此操作。 (以避免宏拉入旧文件)


我知道这仍然可以打开访问权限,但不需要手动导入数据并在完成后清理。 / BLOCKQUOTE>

Hi,
I have text files that are created with comma-delimited records inside them. I am trying to figure out how I can construct a command-line method of importing the records to a MSA table. The end result will be that I can right-click on the .txt file, there will be an option on the context menu that says something like "Add records to ''Modules'' table", and that will bring up a command window that will execute the import command. I have no problem with the context menu (and working with the registry), but I''m not very familiar with the macros, specifically - how would I transfer the file name from the command line to the macro in MSA? Would anyone know of a better method?

解决方案

Im unsure how that would be done, but could you not just open a filebrowser from within access then select teh files to import? Or create a form showing the directory structure, with import buttons?


The text files are generated by another program, and they are constantly being created. I would like to be able to add the records from the text file without having to manually open MS Access.


I think I have a solution but it''s a bit of a mess, and it only works if the incoming files are put into the same folder every time

Use a batch file to rename all files within the incoming directory to a standardized format.

Use the same batch file to open an access database where you have set the startup (under tools) to a form with a single field that has on Gotfocus set to run a macro. (I am sort of new to access and I am unsure if there is another way to run a macro on startup.)

Within the macro use the Transfertext action and in the settings use Import Delimited and set the file name to the standardized file name set with the batch file.

Add the Runcommand action with Exit as the command to your macro if you just want to import the data and nothing else.

You can now either manually move the imported files to an archive folder or add a line in the batch file to do so. (to avoid the macro pulling in old files)

I know this still opens access, but takes away the need to manually import the data and cleans up when it''s done.


这篇关于从命令行向MS Access表添加记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆