如何从文本文件重建对象? [英] How To Rebuild Objects From Text Files?

查看:72
本文介绍了如何从文本文件重建对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经读过一种修复行为不端数据库的方法是将所有数据库对象保存为文本然后从文本

文件重建它们。我使用了Lyle Fairfield发布的以下代码来完成第一步:


Private Sub SaveObjectsAsText()

path = CurrentProject.path& " \ObjectsAsText \"

SaveDataAccessPagesAsText

SaveFormsAsText

SaveReportsAsText

SaveModulesAsText

MsgBoxAll Done Saving Access Objects as Text

End Sub

Private Sub SaveDataAccessPagesAsText()

Dim FileName As String

Dim Name As String

Dim DataAccessPage As AccessObject

每个DataAccessPage在CurrentProject.AllDataAccessPages中

Name = DataAccessPages。姓名

FileName = path&姓名&格式(Now()," yyyymmddhhnn")&

" .txt"

SaveAsText acDataAccessPage,Name,FileName

Next DataAccessPage

MsgBox" All Done Saving Data Access Pages as Text"

End Sub

Private Sub SaveFormsAsText()

Dim FileName As String

Dim Name As String

Dim Form As AccessObject

每个表格在CurrentProject.AllForms

Name = Form.Name

FileName = path&姓名&格式(Now()," yyyymmddhhnn")&

" .txt"

SaveAsText acForm,Name,FileName

下一个表格

MsgBox" All Done Saving Forms as as text"

End Sub

Private Sub SaveReportsAsText()

Dim FileName As String

Dim Name As String

Dim Report As AccessObject

每个报告在CurrentProject.AllReports

Name = Report.Name

FileName = path&姓名&格式(Now()," yyyymmddhhnn")&

" .txt"

SaveAsText acReport,Name,FileName

下一个报告

MsgBox" All Done Saving Reports as Text"

End Sub

Private Sub SaveModulesAsText()

Dim FileName As String

Dim Name As String

Dim Module As AccessObject

For CurrentProject.AllModules中的每个模块

Name = Module.Name

FileName = path&姓名&格式(Now(),yyyymmddhhnn)&

" .txt"

SaveAsText acModule,Name,FileName

下一个模块

MsgBox" All Done Saving Modules as Text"

End Sub


如何重建数据库对象已创建

的文本文件?

解决方案

5月9日上午5:11 *,Wayne< cqdigi ... @ volcanomail.comwrote:


我读过一个修复行为不端数据库的方法是

保存所有数据库将对象作为文本,然后从文本

文件重建它们。 *我使用了Lyle Fairfield发布的以下代码来完成第一步:

Private Sub SaveObjectsAsText()

* * path = CurrentProject.path& " \ObjectsAsText \"

* * SaveDataAccessPagesAsText

* * SaveFormsAsText

* * SaveReportsAsText

* * SaveModulesAsText

* * MsgBox" All Done Saving Access Objects as Text"

End Sub


Private Sub SaveDataAccessPagesAsText( )

* * Dim FileName As String

* * Dim Name As String

* * Dim DataAccessPage As AccessObject

* *对于每个DataAccessPage在CurrentProject.AllDataAccessPages

* * * * Name = DataAccessPages.Name

* * * * FileName = path&姓名&格式(Now()," yyyymmddhhnn)&

" .txt"

* * * * SaveAsText acDataAccessPage,Name,FileName

* *下一个DataAccessPage

MsgBox" All Done Saving Data Pages Pages as Text"

End Sub


Private Sub SaveFormsAsText()

* * Dim FileName As String

* * Dim Name As String

* * Dim Form As AccessObject

* *对于CurrentProject.AllForms中的每个表单

* * * * Name = Form.Name

* * * * FileName = path&姓名&格式(Now()," yyyymmddhhnn)&

" .txt"

* * * * SaveAsText acForm,Name,FileName

* *下一个表格

MsgBox所有完成保存表格作为文本

结束子


私人Sub SaveReportsAsText( )

* * Dim FileName As String

* * Dim Name As String

* * Dim Report As AccessObject

* *对于CurrentProject.AllReports中的每个报告

* * * * Name = Report.Name

* * * * FileName = path&姓名&格式(Now()," yyyymmddhhnn)&

" .txt"

* * * * SaveAsText acReport,Name,FileName

* *下一个报告

MsgBox所有完成保存报告为文本

结束子


Private Sub SaveModulesAsText( )

* * Dim FileName As String

* * Dim Name As String

* * Dim Module As AccessObject

* *对于CurrentProject.AllModules中的每个模块

* * * * Name = Module.Name

* * * * FileName = path&姓名&格式(Now()," yyyymmddhhnn)&

" .txt"

* * * * SaveAsText acModule,Name,FileName

* *下一个模块

MsgBox" All Done Saving Modules as Text"

End Sub


我如何然后从已创建

的文本文件重建数据库对象?



我是否发过半页?整个页面可在以下网址找到:

http: //www.ffdba.com/downloads/Save_...ts_As_Text.htm


http://www.ffdba.com/downloads/Save_...ts_As_Text.htm

http://www.ffdba.com/downloads/Save_...ts_As_Text.dat


http:/ /www.ffdba.com/downloads/Save_...ts_As_Text.dat

供下载,


使用整个页面或模块。


Wayne写道:


我读过一个修复行为不端数据库的方法是

保存所有da将tabase对象作为文本,然后从文本

文件重建它们。我使用了Lyle Fairfield发布的以下代码来完成第一步:



[snip]
< blockquote class =post_quotes>
如何从已创建

的文本文件重建数据库对象?



就像有一个SaveAsText()函数一样,还有一个LoadFromText()

函数。后者是用来重建对象的。


-

Rick Brandt,Microsoft Access MVP

电子邮件( (视情况而定)...

在Hunter dot com的RBrandt


5月9日,5:33 * am,lyle fairfield< lyle.fairfi ... @ gmail.comwrote:


5月9日,5:11 * am,Wayne< cqdigi .. 。@ volcanomail.com写道:


我读过一个修复行为不端数据库的方法是将所有数据库对象保存为
文本,然后从文本

文件重建它们。 *我使用了Lyle Fairfield发布的以下代码来完成第一步:


Private Sub SaveObjectsAsText ()

* * path = CurrentProject.path& " \ObjectsAsText \"

* * SaveDataAccessPagesAsText

* * SaveFormsAsText

* * SaveReportsAsText

* * SaveModulesAsText

* * MsgBox" All Done Saving Access Objects as Text"

End Sub


Private Sub SaveDataAccessPagesAsText()

* * Dim FileName As String

* * Dim Name As String

* * Dim DataAccessPage As AccessObject

* *对于每个DataAccessPage在CurrentProject.AllDataAccessPages中

* * * * Name = DataAccessPages.Name

* * * * FileName = path &安培;姓名&格式(Now()," yyyymmddhhnn)&

" .txt"

* * * * SaveAsText acDataAccessPage,Name,FileName

* *下一个DataAccessPage

MsgBox" All Done Saving Data Pages pages as text"

End Sub


Private Sub SaveFormsAsText()

* * Dim FileName As String

* * Dim Name As String

* * Dim表单作为AccessObject

* *对于CurrentProject.AllForms中的每个表单

* * * * Name = Form.Name

* * * * FileName =路径&姓名&格式(Now()," yyyymmddhhnn)&

" .txt"

* * * * SaveAsText acForm,Name,FileName

* *下一个表格

MsgBox"所有完成保存表格作为文本

结束子


Private Sub SaveReportsAsText()

* * Dim FileName As String

* * Dim Name As String

* * Dim Report As AccessObject

* *对于CurrentProject.AllReports中的每个报表

* * * * Name = Report.Name

* * * * FileName = path &安培;姓名&格式(Now()," yyyymmddhhnn)&

" .txt"

* * * * SaveAsText acReport,Name,FileName

* *下一份报告

MsgBox所有完成保存报告为文本

结束次级


Private Sub SaveModulesAsText()

* * Dim FileName As String

* * Dim Name As String

* * Dim Module As AccessObject

* *对于CurrentProject.AllModules中的每个模块

* * * * Name = Module.Name

* * * * FileName = path &安培;姓名&格式(Now()," yyyymmddhhnn)&

" .txt"

* * * * SaveAsText acModule,Name,FileName

* *下一个模块

MsgBox" All Done Saving Modules as text"

End Sub


如何从已创建

的文本文件重建数据库对象?



我是否发过半页?整个页面可在以下网址找到:

http: //www.ffdba.com/downloads/Save_...ts_As_Text.htm

orhttp://www.ffdba.com/downloads/Save_ADP_Objects_As_Text.htm

http://www.ffdba.com/downloads/Save _... ts_As_Text.dat

orhttp://www.ffdba.com/downloads/Save_ADP_Objects_As_Text.dat

下载,


使用整个页面或模块。



LoadFromText是一个隐藏且未记录的程序。

值得注意的是

LoadFromText AcObjectType, ObjectName,FilePath

用FilePath中的任何指令覆盖名为ObjectName的对象。

有,TTBOMK,没有从中恢复。旧物体现在属于

年龄,但不是你。多年来LoadFromText从来没有让我失望过,但是如果我给出了错误或愚蠢的指示,它会带着

出来,没有任何警告,就像它执行任何其他

说明。

总之,备份和/或安全副本的制作可能是一个值得花费的时间和资源,在使用之前

LoadFromText。

巧合的是,我现在正在这样做,努力改变所有

" Guidance"对象和对它的引用,对StudentSuccess

对象。不是政治盛大吗?我希望StudentSuccess的工作人员比指导人员更有效。

我做的第一件事就是制作ADP的安全副本(它可以
已经是MDB)文件。


I''ve read that one method of repairing a misbehaving database is to
save all database objects as text and then rebuild them from the text
files. I''ve used the following code posted by Lyle Fairfield to
accomplish the first step:

Private Sub SaveObjectsAsText()
path = CurrentProject.path & "\ObjectsAsText\"
SaveDataAccessPagesAsText
SaveFormsAsText
SaveReportsAsText
SaveModulesAsText
MsgBox "All Done Saving Access Objects as Text"
End Sub
Private Sub SaveDataAccessPagesAsText()
Dim FileName As String
Dim Name As String
Dim DataAccessPage As AccessObject
For Each DataAccessPage In CurrentProject.AllDataAccessPages
Name = DataAccessPages.Name
FileName = path & Name & Format(Now(), "yyyymmddhhnn") &
".txt"
SaveAsText acDataAccessPage, Name, FileName
Next DataAccessPage
MsgBox "All Done Saving Data Access Pages as Text"
End Sub
Private Sub SaveFormsAsText()
Dim FileName As String
Dim Name As String
Dim Form As AccessObject
For Each Form In CurrentProject.AllForms
Name = Form.Name
FileName = path & Name & Format(Now(), "yyyymmddhhnn") &
".txt"
SaveAsText acForm, Name, FileName
Next Form
MsgBox "All Done Saving Forms as Text"
End Sub
Private Sub SaveReportsAsText()
Dim FileName As String
Dim Name As String
Dim Report As AccessObject
For Each Report In CurrentProject.AllReports
Name = Report.Name
FileName = path & Name & Format(Now(), "yyyymmddhhnn") &
".txt"
SaveAsText acReport, Name, FileName
Next Report
MsgBox "All Done Saving Reports as Text"
End Sub
Private Sub SaveModulesAsText()
Dim FileName As String
Dim Name As String
Dim Module As AccessObject
For Each Module In CurrentProject.AllModules
Name = Module.Name
FileName = path & Name & Format(Now(), "yyyymmddhhnn") &
".txt"
SaveAsText acModule, Name, FileName
Next Module
MsgBox "All Done Saving Modules as Text"
End Sub

How do I then rebuild the database objects from the text files that
have been created?

解决方案

On May 9, 5:11*am, Wayne <cqdigi...@volcanomail.comwrote:

I''ve read that one method of repairing a misbehaving database is to
save all database objects as text and then rebuild them from the text
files. *I''ve used the following code posted by Lyle Fairfield to
accomplish the first step:

Private Sub SaveObjectsAsText()
* * path = CurrentProject.path & "\ObjectsAsText\"
* * SaveDataAccessPagesAsText
* * SaveFormsAsText
* * SaveReportsAsText
* * SaveModulesAsText
* * MsgBox "All Done Saving Access Objects as Text"
End Sub

Private Sub SaveDataAccessPagesAsText()
* * Dim FileName As String
* * Dim Name As String
* * Dim DataAccessPage As AccessObject
* * For Each DataAccessPage In CurrentProject.AllDataAccessPages
* * * * Name = DataAccessPages.Name
* * * * FileName = path & Name & Format(Now(), "yyyymmddhhnn") &
".txt"
* * * * SaveAsText acDataAccessPage, Name, FileName
* * Next DataAccessPage
MsgBox "All Done Saving Data Access Pages as Text"
End Sub

Private Sub SaveFormsAsText()
* * Dim FileName As String
* * Dim Name As String
* * Dim Form As AccessObject
* * For Each Form In CurrentProject.AllForms
* * * * Name = Form.Name
* * * * FileName = path & Name & Format(Now(), "yyyymmddhhnn") &
".txt"
* * * * SaveAsText acForm, Name, FileName
* * Next Form
MsgBox "All Done Saving Forms as Text"
End Sub

Private Sub SaveReportsAsText()
* * Dim FileName As String
* * Dim Name As String
* * Dim Report As AccessObject
* * For Each Report In CurrentProject.AllReports
* * * * Name = Report.Name
* * * * FileName = path & Name & Format(Now(), "yyyymmddhhnn") &
".txt"
* * * * SaveAsText acReport, Name, FileName
* * Next Report
MsgBox "All Done Saving Reports as Text"
End Sub

Private Sub SaveModulesAsText()
* * Dim FileName As String
* * Dim Name As String
* * Dim Module As AccessObject
* * For Each Module In CurrentProject.AllModules
* * * * Name = Module.Name
* * * * FileName = path & Name & Format(Now(), "yyyymmddhhnn") &
".txt"
* * * * SaveAsText acModule, Name, FileName
* * Next Module
MsgBox "All Done Saving Modules as Text"
End Sub

How do I then rebuild the database objects from the text files that
have been created?

Did I ever post this half-page? The whole pages can be found at:

http://www.ffdba.com/downloads/Save_...ts_As_Text.htm
or
http://www.ffdba.com/downloads/Save_...ts_As_Text.htm

http://www.ffdba.com/downloads/Save_...ts_As_Text.dat
or
http://www.ffdba.com/downloads/Save_...ts_As_Text.dat
for download,

Use the whole page or module.


Wayne wrote:

I''ve read that one method of repairing a misbehaving database is to
save all database objects as text and then rebuild them from the text
files. I''ve used the following code posted by Lyle Fairfield to
accomplish the first step:

[snip]

How do I then rebuild the database objects from the text files that
have been created?

Just as there is a SaveAsText() function there is also a LoadFromText()
function. The latter is whaty you would use to rebuild the objects.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com



On May 9, 5:33*am, lyle fairfield <lyle.fairfi...@gmail.comwrote:

On May 9, 5:11*am, Wayne <cqdigi...@volcanomail.comwrote:

I''ve read that one method of repairing a misbehaving database is to
save all database objects as text and then rebuild them from the text
files. *I''ve used the following code posted by Lyle Fairfield to
accomplish the first step:

Private Sub SaveObjectsAsText()
* * path = CurrentProject.path & "\ObjectsAsText\"
* * SaveDataAccessPagesAsText
* * SaveFormsAsText
* * SaveReportsAsText
* * SaveModulesAsText
* * MsgBox "All Done Saving Access Objects as Text"
End Sub

Private Sub SaveDataAccessPagesAsText()
* * Dim FileName As String
* * Dim Name As String
* * Dim DataAccessPage As AccessObject
* * For Each DataAccessPage In CurrentProject.AllDataAccessPages
* * * * Name = DataAccessPages.Name
* * * * FileName = path & Name & Format(Now(), "yyyymmddhhnn")&
".txt"
* * * * SaveAsText acDataAccessPage, Name, FileName
* * Next DataAccessPage
MsgBox "All Done Saving Data Access Pages as Text"
End Sub

Private Sub SaveFormsAsText()
* * Dim FileName As String
* * Dim Name As String
* * Dim Form As AccessObject
* * For Each Form In CurrentProject.AllForms
* * * * Name = Form.Name
* * * * FileName = path & Name & Format(Now(), "yyyymmddhhnn")&
".txt"
* * * * SaveAsText acForm, Name, FileName
* * Next Form
MsgBox "All Done Saving Forms as Text"
End Sub

Private Sub SaveReportsAsText()
* * Dim FileName As String
* * Dim Name As String
* * Dim Report As AccessObject
* * For Each Report In CurrentProject.AllReports
* * * * Name = Report.Name
* * * * FileName = path & Name & Format(Now(), "yyyymmddhhnn")&
".txt"
* * * * SaveAsText acReport, Name, FileName
* * Next Report
MsgBox "All Done Saving Reports as Text"
End Sub

Private Sub SaveModulesAsText()
* * Dim FileName As String
* * Dim Name As String
* * Dim Module As AccessObject
* * For Each Module In CurrentProject.AllModules
* * * * Name = Module.Name
* * * * FileName = path & Name & Format(Now(), "yyyymmddhhnn")&
".txt"
* * * * SaveAsText acModule, Name, FileName
* * Next Module
MsgBox "All Done Saving Modules as Text"
End Sub

How do I then rebuild the database objects from the text files that
have been created?


Did I ever post this half-page? The whole pages can be found at:

http://www.ffdba.com/downloads/Save_...ts_As_Text.htm
orhttp://www.ffdba.com/downloads/Save_ADP_Objects_As_Text.htm

http://www.ffdba.com/downloads/Save_...ts_As_Text.dat
orhttp://www.ffdba.com/downloads/Save_ADP_Objects_As_Text.dat
for download,

Use the whole page or module.

LoadFromText is a hidden and undocumented procedure.
It may be worthwhile to note that
LoadFromText AcObjectType, ObjectName, FilePath
overwrites the object named ObjectName with whatever instructions are
in FilePath.
There is, TTBOMK, NO recovery from this. The old object now belongs to
the ages, but not to you. Over many years LoadFromText has never
failed me, but if I give it wrong or foolish instructions, it carries
them out, without any warning, just as it carries out any other
instructions.
In summary, the making of backups and/or safe copies may be a
worthwhile expenditure of time and resources before using
LoadFromText.
Coincidentally, I am doing that right now, in an effort to change all
"Guidance" objects and references to same, to "StudentSuccess"
objects. Ain''t politics grand? I expect that StudentSuccess staff will
be much more effective than Guidance staff.
The first thing I did was to make a safe copy of the ADP (it could
have been MDB) file.


这篇关于如何从文本文件重建对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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