将查询从一个Access DB复制到另一个Access DB,从而消除重复 [英] Copying queries from one Access DB to another eliminating duplicates

查看:95
本文介绍了将查询从一个Access DB复制到另一个Access DB,从而消除重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我是使用Access进行VB应用程序开发的新手。我的任务是将查询从一个数据库复制到另一个数据库,而不复制目标数据库中已存在的查询(查询的名称被视为重复因素)。


我尝试使用DoCmd对象,使用TransferDatabase方法。但我不能使用DoCmd对象本身。我已将该应用程序引用到MS DAO 3.6。我是否需要将其引用到某些东西或者我在做一些内在错误的事情。


任何反馈都将被赞赏

Hi,

I am new to VB application development with Access. I have a task of copying queries from one DB to another, without duplicationg the ones that are already existing in the destination DB (the names of the queries are taken to be the duplicating factor).


i tried using the DoCmd object, with the method TransferDatabase. But I''m not able use the DoCmd object itself. I have referenced the app to MS DAO 3.6. Do I need to reference it to something eles or am I doing something inherently wrong.

Any feedback would be appreciated

推荐答案

DoCmd具有复制对象操作。以下内容直接来自Access帮助。如果有什么你不明白的,请告诉我。

DoCmd.CopyObject destinationdatabase,newname,ObjectType,sourceobjectname

DoCmd has a copy object action. The following is taken directly from Access Help. If there is anything you don''t understand just let me know.
DoCmd.CopyObject destinationdatabase, newname, ObjectType, sourceobjectname


CopyObject操作具有以下参数。

目标数据库

目标数据库的有效路径和文件名。在宏窗口的操作参数部分的目标数据库框中输入路径和文件名。如果要选择当前数据库,请将此参数留空。

注意
此参数仅在Microsoft Access数据库环境(.mdb)中可用。在Access项目环境(.adp)中使用此操作时,目标数据库参数必须为空。

如果在库数据库中运行包含CopyObject操作的宏并保留此参数为空,Microsoft Access会将对象复制到库数据库中。

新名称

新名称物体。复制到其他数据库时,请将此参数留空以保留相同的名称。

源对象类型

要复制的对象类型。点击查询表单报告模块的。 数据访问页服务器视图图表存储过程。要复制在数据库窗口中选择的对象,请将此参数留空。

源对象名称

名称要复制的对象。 源对象名称框显示源对象类型参数选择的类型的数据库中的所有对象。在源对象名称框中,单击要复制的对象。如果将源对象类型参数留空,则也将此参数留空。如果在库数据库中运行包含CopyObject操作的宏,Microsoft Access将首先在库数据库中查找具有此名称的对象,然后在当前数据库中查找。


备注


您必须为此操作输入目标数据库和新名称参数中的一个或两个的值。


如果将源对象类型和源对象名称参数留空,Microsoft Access将复制在数据库窗口中选择的对象。要在数据库窗口中选择对象,可以使用SelectObject操作,并将数据库窗口参数设置为是。

CopyObject操作类似于在数据库窗口中选择对象,单击编辑菜单上的复制,然后单击编辑菜单上的粘贴。将出现粘贴为对话框,以便为对象指定新名称。 CopyObject操作自动执行所有这些步骤。


在宏运行CopyObject操作之前,目标数据库的路径和文件名必须存在。如果它们不存在,Microsoft Access将显示错误消息。
The CopyObject action has the following arguments.

Destination Database
A valid path and file name for the destination database. Enter the path and file name in the Destination Database box in the Action Arguments section of the Macro window. Leave this argument blank if you want to select the current database.
Note
This argument is only available in the Microsoft Access database environment (.mdb). When using this action in an Access project environment (.adp), the Destination Database argument must be blank.

If you run a macro containing the CopyObject action in a library database and leave this argument blank, Microsoft Access will copy the object into the library database.

New Name
A new name for the object. When copying to a different database, leave this argument blank to keep the same name.

Source Object Type
The object type you want to copy. Click Table, Query, Form, Report, Macro, Module. Data Access Page, Server View, Diagram, Stored Procedure. To copy the object selected in the Database window, leave this argument blank.

Source Object Name
The name of the object to be copied. The Source Object Name box shows all objects in the database of the type selected by the Source Object Type argument. In the Source Object Name box, click the object to copy. If you leave the Source Object Type argument blank, leave this argument blank also. If you run a macro containing the CopyObject action in a library database, Microsoft Access looks for the object with this name first in the library database, then in the current database.


Remarks

You must enter a value for either one or both of the Destination Database and New Name arguments for this action.

If you leave the Source Object Type and Source Object Name arguments blank, Microsoft Access copies the object selected in the Database window. To select an object in the Database window, you can use the SelectObject action with the In Database Window argument set to Yes.

The CopyObject action is similar to selecting an object in the Database window, clicking Copy on the Edit menu, and then clicking Paste on the Edit menu. The Paste As dialog box appears so you can give the object a new name. The CopyObject action performs all of these steps automatically.

The path and file name of the destination database must exist before the macro runs the CopyObject action. If they don''t exist, Microsoft Access displays an error message.



DoCmd有一个复制对象动作。以下内容直接来自Access帮助。如果有什么你不明白的,请告诉我。

DoCmd.CopyObject destinationdatabase,newname,ObjectType,sourceobjectname



嗯,我的问题是,我无法使用DoCmd作为对象。对不起,如果我听起来像个白痴。我有一个VB Windows应用程序。已将其引用到Microsoft DAO 3.6。我尝试使用DoCmd来调用TransferDatabase方法,但我不能说''DoCmd''没有定义。甚至intellisense都没有显示出来。


你能帮忙吗?

Well, my problem is, I''m not able to use DoCmd as an object. Sorry if I sound like a moron. I have a VB Windows application. Have referenced it to Microsoft DAO 3.6. I try to use DoCmd for calling the TransferDatabase method, but I can''t as it says ''DoCmd'' is not defined. Even the intellisense does not show it up.

Can you please help?


DoCmd是VBA的Access特定命令。这意味着它不会在VB6中运行,也不会在Visual Basic的许多其他版本中运行。


你说你是从一个Access DB导入到另一个,所以你应该没有麻烦使用这个INSIDE正在转移INTO的Access DB ...或者你在Access DB内部转移自。


问候,

Scott
DoCmd is an Access specific command of VBA. That means it won''t run in VB6, nor in any other of the many flavors of Visual Basic.

You say you are importing from one Access DB to another, so you should have no troubles using this INSIDE the Access DB you are transferring INTO... OR inside the Access DB you are transferring FROM.

Regards,
Scott


这篇关于将查询从一个Access DB复制到另一个Access DB,从而消除重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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