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 SaveObjectsAsTe xt()
path = CurrentProject. path & "\ObjectsAsText \"
SaveDataAccessP agesAsText
SaveFormsAsText
SaveReportsAsTe xt
SaveModulesAsTe xt
MsgBox "All Done Saving Access Objects as Text"
End Sub
Private Sub SaveDataAccessP agesAsText()
Dim FileName As String
Dim Name As String
Dim DataAccessPage As AccessObject
For Each DataAccessPage In CurrentProject. AllDataAccessPa ges
Name = DataAccessPages .Name
FileName = path & Name & Format(Now(), "yyyymmddhh nn") &
".txt"
SaveAsText acDataAccessPag e, 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(), "yyyymmddhh nn") &
".txt"
SaveAsText acForm, Name, FileName
Next Form
MsgBox "All Done Saving Forms as Text"
End Sub
Private Sub SaveReportsAsTe xt()
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(), "yyyymmddhh nn") &
".txt"
SaveAsText acReport, Name, FileName
Next Report
MsgBox "All Done Saving Reports as Text"
End Sub
Private Sub SaveModulesAsTe xt()
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(), "yyyymmddhh nn") &
".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?
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 SaveObjectsAsTe xt()
path = CurrentProject. path & "\ObjectsAsText \"
SaveDataAccessP agesAsText
SaveFormsAsText
SaveReportsAsTe xt
SaveModulesAsTe xt
MsgBox "All Done Saving Access Objects as Text"
End Sub
Private Sub SaveDataAccessP agesAsText()
Dim FileName As String
Dim Name As String
Dim DataAccessPage As AccessObject
For Each DataAccessPage In CurrentProject. AllDataAccessPa ges
Name = DataAccessPages .Name
FileName = path & Name & Format(Now(), "yyyymmddhh nn") &
".txt"
SaveAsText acDataAccessPag e, 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(), "yyyymmddhh nn") &
".txt"
SaveAsText acForm, Name, FileName
Next Form
MsgBox "All Done Saving Forms as Text"
End Sub
Private Sub SaveReportsAsTe xt()
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(), "yyyymmddhh nn") &
".txt"
SaveAsText acReport, Name, FileName
Next Report
MsgBox "All Done Saving Reports as Text"
End Sub
Private Sub SaveModulesAsTe xt()
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(), "yyyymmddhh nn") &
".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?
Comment