文件描述符访问文件_访问文件比较

文件描述符访问文件

访问文件比较 (Comparison Of Access Files)

CCAccessComparison.zip CCAccessComparison.zip

目录 (Table of Contents)

1 About CCAccessComparison

1关于CCAccessComparison

1.1 Features of CCAccessComparison

1.1 CCAccessComparison的功能

2 How to use

2使用方法

2.1 One time preparation

2.1一次准备

2.1.1 Entering the path to Meld.exe

2.1.1输入Meld.exe的路径

2.1.2 Adjusting VBA References

2.1.2调整VBA参考

2.2 Entering the needed information

2.2输入所需的信息

2.3 Additional Information

2.3附加信息

2.3.1 HTML Message Box

2.3.1 HTML消息框

2.3.2 clsCCADO

2.3.2 clsCCADO

2.3.3 clsCCErrors

2.3.3 clsCCErrors

2.3.4 modRenameObjects

2.3.4 modRenameObjects

2.3.5 Comparing ADPs

2.3.5比较ADP

1关于CCAccessComparison (1 About CCAccessComparison)

If you are developing a database (frontend, backend or both in one) with Access you know that it’s not so easy to keep the overview of all the file versions you have saved as copy of your work. Maybe you want to get into an older project and forgot what were the changes between the current version and the last one or someone else has programmed something into your frontend and you want to know what has been changed.

如果您要使用Access开发数据库(前端,后端或两者合二为一),您会知道要保存已保存为工作副本的所有文件版本的概述并不容易。 也许您想进入一个较旧的项目,而忘记了当前版本和上一个版本之间的更改,或者其他人已经在前端编程了某些内容,并且想知道更改了什么。

Unfortunately Access has no possibility to compare two Access files to see all the differences. You can of course find commercial tools to compare or freeware tools to compare two text files or a directory of text files, but they cannot look into the code of an Access file.

不幸的是,Access无法比较两个Access文件以查看所有差异。 当然,您可以找到进行比较的商业工具或可以比较两个文本文件或文本文件目录的免费软件工具,但是它们无法查看Access文件的代码。

So if you want to get a quick overview of all the changes between two Access files you need to have all objects of an Access file as text files on your harddisk. This is what this tool primarily does: It exports all objects of an Access file as plain text files and then starts a tool which is able to compare two directories of text files and shows the differences.

因此,如果要快速了解两个Access文件之间的所有更改,则需要将Access文件的所有对象作为文本文件放在硬盘上。 此工具的主要作用是:将Access文件的所有对象导出为纯文本文件,然后启动一个能够比较文本文件的两个目录并显示差异的工具。

After a long search I found the tool "Meld" which does exactly this, it’s free to use. So to use the CCAccessComparison tool you need to download and install "Meld". It was developed using version 3.14.2 and should also work with newer versions. You can get it here.

经过长时间的搜索,我发现工具“ Meld”完​​全可以做到这一点,它是免费使用的。 因此,要使用CCAccessComparison工具,您需要下载并安装“ Meld”。 它是使用3.14.2版开发的,并且也应该与较新版本一起使用。 你可以在这里得到。

()

1.1 Features of CCAccessComparison

 

1.1 CCAccessComparison的功能

  • Compares two Access files (MDB/ACCDB/ADP, as long as it can be opened with your version of Access)

    比较两个Access文件(MDB / ACCDB / ADP,只要可以用您的Access版本打开即可)
  • Outputs all objects (except table data) as text files in separated folders

    将所有对象(表数据除外)输出为单独文件夹中的文本文件
  • Saves folder and file paths in a project table to make it possible to reuse former file selections

    将文件夹和文件路径保存在项目表中,以便可以重复使用以前的文件选择
  • Automatically starts "Meld" and starts the comparison in Meld using the output folders of the compared Access files

    使用比较的Access文件的输出文件夹自动启动“合并”并在Meld中开始比较
()

2 How to use

2使用方法

()

2.1 One time preparation

2.1一次准备

()

2.1.1 Entering the path to Meld.exe.

2.1.1输入Meld.exe的路径。

Open the module "modCompare" in the VBA editor. At the top you’ll find a constant definition with the path to Meld.exe. Enter the path where you’ve installed it in the same way as you see in the example:

在VBA编辑器中打开模块“ modCompare”。 在顶部,您将找到带有Meld.exe路径的常量定义。 输入与示例中相同的安装路径:

Public Const cMeldPath As String = """C:\Program Files (x86)\Tools\Meld\Meld.exe"""

Please make sure that the double quotes remains in the constant. The tool works without Meld, in that case you’ll get only the text output files and an error occurs when it tries to start Meld. You can use any other tool you want to compare the text files.

请确保双引号保持不变。 该工具可以在不使用Meld的情况下使用,在这种情况下,您将仅获得文本输出文件,并且在尝试启动Meld时会发生错误。 您可以使用任何其他工具来比较文本文件。


2.1.2调整VBA参考 (
2.1.2 Adjusting VBA References)

The tool was written using Access 2007 and converted to MDB for use with Access 2003. VBA often automatically converts references to the newest installed Office version so to use it you must change the references in VBA ("Tools" - "References") to the version you use on your machine. For example there is a reference to ADO 6.0 contained that works starting with Windows Vista, but if you use Windows XP you must change that to ADO 2.8. The same with Office which is Office 15 here; you must change it to the Office library you use on your machine. Here are the references in the ACCDB version:

该工具是使用Access 2007编写的,并转换为MDB以与Access 2003一起使用。VBA通常会自动将引用转换为最新安装的Office版本,因此要使用它,必须将VBA中的引用(“工具”-“引用”)更改为您在计算机上使用的版本。 例如,有一个对ADO 6.0的引用,该引用可从Windows Vista开始使用,但是如果使用Windows XP,则必须将其更改为ADO 2.8。 Office与此处的Office 15相同; 您必须将其更改为在计算机上使用的Office库。 以下是ACCDB版本中的参考:

References.png
ReferencesMDB.png
()

2.2 Entering the needed information

2.2输入所需的信息

When you start the tool the "Projects" form will be started automatically. You can now enter a project name (needed) and optionally a version number. This makes it easier to find the right project later.

启动该工具时,将自动启动“项目”表单。 现在,您可以输入项目名称(需要)和可选的版本号。 这使以后查找正确的项目变得更加容易。

ProjectForm.png

Then you only need to select the two desired Access files you want to compare and optionally enter a description. The "Last Compare Date" will automatically be set when you start the comparison.

然后,您只需选择要比较的两个所需的Access文件,并有选择地输入描述。 开始比较时,将自动设置“上次比较日期”。

At the end you only need to save the record and click "Compare Files". Now the tool starts with opening the first Access file and exporting all objects as text files (in case of queries the SQL text will be saved additionally in a separate file). Next the same is done with the second Access file in the other output folder. At the end a compare batch file will be created (because the "Shell" command of VBA cannot handle very long strings) which then will be executed. Here you can of course configure your own compare tool if you want. I found that Meld is one of the greatest as it can handle Unicode characters and also compares folder structures and file contents, also the way it displays differences is really a new idea where the two comparison columns scrolls independently from each other and so on.

最后,您只需要保存记录并单击“比较文件”。 现在,该工具首先打开第一个Access文件并将所有对象导出为文本文件(在查询的情况下,SQL文本将另外保存在单独的文件中)。 接下来,对另一个输出文件夹中的第二个Access文件执行相同的操作。 最后,将创建一个比较批处理文件(因为VBA的“ Shell”命令无法处理很长的字符串),然后将执行该文件。 当然,如果需要,您当然可以在这里配置自己的比较工具。 我发现Meld是最出色的应用程序之一,因为它可以处理Unicode字符,还可以比较文件夹结构和文件内容,而且显示差异的方式实际上是一个新的想法,即两个比较列彼此独立滚动等等。


2.3附加信息 (
2.3 Additional Information)

For the export the not officially documented "SaveAsText" method is used which can export all object types (except tables) as a plain text file. You can also use the pendant "LoadFromText" to load such text files back into an Access file. As this doesn’t work with tables the tool uses DAO to export all property information about the tables. Additionally all index information and also all relations to other tables are included in the output file. As this uses the property names these output files could theoretically also be used to recreate the table structures in a new Access file.

对于导出,使用未正式记录的“ SaveAsText”方法,该方法可以将所有对象类型(表除外)导出为纯文本文件。 您也可以使用挂件“ LoadFromText”将此类文本文件加载回Access文件中。 由于这不适用于表,因此该工具使用DAO导出有关表的所有属性信息。 另外,所有索引信息以及与其他表的所有关系都包含在输出文件中。 由于使用了属性名称,因此这些输出文件理论上也可以用于在新的Access文件中重新创建表结构。

The tool contains some add-ons which you also may find helpful and which you can implement in your own projects if you want.

该工具包含一些附加组件,这些附加组件也可能会有所帮助,并且您可以根据需要在自己的项目中实现这些附加组件。


2.3.1 HTML消息框 (
2.3.1 HTML Message Box)

The tool contains my HTML message box which was developed to completely replace the MsgBox command of VBA. With this you can display any message in the same way as the MsgBox command does, the parameters are the same as in MsgBox, but there are a lot more.

该工具包含我HTML消息框,该消息框是为完全替代VBA的MsgBox命令而开发的。 这样,您可以以与MsgBox命令相同的方式显示任何消息,参数与MsgBox中的相同,但还有更多。

If you supply a HTML formatted text it will be displayed using the Internet Explorer of your system on which the web control is based on. The additional parameters also allows to display the result of a SQL command or the content of an ADO recordset (it was developed for ADPs so sorry, no DAO recordset supported but you can also open Access files with ADO) as a HTML formatted table which also supports conditional formatting in the HTML table and so on. It should not hard to find out how it works if you look into the documented code.

如果提供HTML格式的文本,它将使用Web控件所基于的系统的Internet Explorer进行显示。 附加参数还允许显示SQL命令的结果或ADO记录集的内容(它是为ADP开发的,很抱歉,不支持DAO记录集,但您也可以使用ADO打开Access文件)作为HTML格式的表,该表也可以支持HTML表中的条件格式等等。 查看文档中的代码,不难发现它是如何工作的。

Without using the additional features the HTML message box can simply be used with any of your "Msgbox" command lines by simply adding a "." Between "Msg" and "Box":

无需使用其他功能,只需通过添加“”就可以将HTML消息框与任何“ Msgbox”命令行一起使用。 在“消息”和“框”之间:

Msg.Box "Test"

The code also contains disabled code blocks for exporting the message to Excel which you can enable if you’ve Excel installed. The tool uses the HTML message box for displaying error messages.

该代码还包含用于将消息导出到Excel的禁用代码块,如果已安装Excel,则可以启用该代码块。 该工具使用HTML消息框显示错误消息。


2.3.2 clsCCADO (
2.3.2 clsCCADO)

The tool needs that only because the HTML message box needs some functions of it. This is a library of useful functions if you work often with ADO which I’ve developed over years. The functions are documented in the code.

该工具之所以需要它,是因为HTML消息框需要一些功能。 如果您经常使用我多年来开发的ADO,那么这是一个有用的函数库。 这些功能记录在代码中。


2.3.3 clsCCErrors (
2.3.3 clsCCErrors)

This is a class to handle the errors which uses the above classes. It supports writing VBA errors into an HTML formatted error log saved locally in an "Errors" subfolder which is automatically created in the project’s folder. It prepares the HTML message box output for VBA errors and additionally shows errors which maybe happened in an ADO object. Same as above: It was developed for ADPs so DAO is not used here.

这是使用上述类来处理错误的类。 它支持将VBA错误写入HTML格式的错误日志中,该日志保存在本地的“错误”子文件夹中,该子文件夹是在项目文件夹中自动创建的。 它为VBA错误准备HTML消息框输出,并另外显示可能在ADO对象中发生的错误。 与上面相同:它是为ADP开发的,因此此处不使用DAO。


2.3.4 modRenameObjects (
2.3.4 modRenameObjects)

This contains two little procedures which I often use to prepare a form after Access has automatically created it from a table or query. One is to correct the naming of all controls which contains a ControlSource and their corresponding label control, the other sets a defined format for continuous forms. I left that tools in the database, maybe you also find it useful for your project. It is not actively used in the tool and can be removed.

这包含两个小的过程,在Access从表或查询自动创建表单后,我经常使用它们准备表单。 一种是纠正包含ControlSource及其相应标签控件的所有控件的命名,另一种是设置连续表格的定义格式。 我将该工具留在了数据库中,也许您也发现它对您的项目有用。 它没有在工具中积极使用,可以删除。


2.3.5比较ADP (
2.3.5 Comparing ADPs)

If you want to compare ADP files or older MDB files you need to have an Access version installed which is able to open them. So if you want to compare ADP files the last version which supports that is Access 2010. If you have Access 2013 or newer the tool displays error messages as Access 2013 cannot open ADPs anymore. The same is true for older MDB files. So to successfully compare such files you need to run the tool on a computer which has an older Access version installed. Access 2013 must not be installed there because the tool automatically uses the newest installed Access version to open the Access files.

如果要比较ADP文件或较旧的MDB文件,则需要安装一个可以打开它们的Access版本。 因此,如果要比较ADP文件,则支持的最后一个版本是Access2010。如果您具有Access 2013或更高版本,该工具将显示错误消息,因为Access 2013无法再打开ADP。 较旧的MDB文件也是如此。 因此,要成功比较此类文件,您需要在装有旧版Access版本的计算机上运行该工具。 不能在此处安装Access 2013,因为该工具会自动使用最新安装的Access版本打开Access文件。

Have fun in comparing your Access files and thanks to Kai Willadsen for the great diff tool "Meld".

在比较您的Access文件时很开心,并感谢Kai Willadsen提供了出色的差异工具“ Meld”。

Christian Coppes

克里斯蒂安·科普斯

翻译自: https://www.experts-exchange.com/articles/28520/Comparison-Of-Access-Files.html

文件描述符访问文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值