INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS
Come Join Us!
Are you a
Computer / IT professional?
Join Tek-Tips now!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- One-Click Access To Your
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site
(Download This Button Today!)
"...This site is awesome!...Things I have been trying to figure out for weeks, I got the answer in hours!..."
Where in the world do Tek-Tips members come from?
DB corrupt, get rid of error
Posted: 8 Jan 04 (Edited 14 Jun 07)
Applies to at least Access 97 and 2000.
See also Knowledge Base Article - 304548:
If you import any form(s) containing vb-code into another database, the result can be db corruption.
You will get error messages like 'The event 'OnClick' has caused errors' or 'Unable to save - Network connection may have been lost' or similar.
Sometimes a simple 'Compact and repair' will suffice.
Another option is to decompile the database.
Refer to http://www.granite.ab.ca/access/decompile.htm
Great thanks to RoyVidar for this hint.
If not, then for each form you must: (Code follows below list)
Having done this, you can import your forms to a new db, paste the code from the text file(s) back to the respective form and set the 'HasModule' property to 'Yes'
- Open in code view
- Copy/Paste code to a text file
- Set 'HasModule' property to 'No', this will erase all code!
Here's some code that will save all modules to text files, credits to DeanWilliams!!
Public Function SaveCodeModules()
Dim dbs As DAO.Database
Dim strCode As String
Set dbs = CurrentDb
For Each vbComp In vbe.VBProjects(1).VBComponents
strCode = .CodeModule.Lines(1, .CodeModule.CountOfLines)
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("C:\Code\" & .Name & ".txt")
Dim frm As Form
Dim rpt As Report
Dim obj As AccessObject
For Each obj In CurrentProject.AllForms
DoCmd.OpenForm obj.Name, acDesign
Set frm = Forms(obj.Name)
frm.HasModule = False
DoCmd.Close acForm, frm.Name, acSaveYes
For Each obj In CurrentProject.AllReports
DoCmd.OpenReport obj.Name, acDesign
Set rpt = Reports(obj.Name)
rpt.HasModule = False
DoCmd.Close acReport, rpt.Name, acSaveYes
Add the code in red if you want to set the HasModule property of your forms and reports set to No.
Credits to DeanWilliams for the code snippet, one of the VIP participants of forum705: Microsoft: Access Modules (VBA Coding) and other Access fora.
Back to Microsoft: Access Modules (VBA Coding) FAQ Index
Back to Microsoft: Access Modules (VBA Coding) Forum
Join Tek-Tips® Today!
Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.
Here's Why Members Love Tek-Tips Forums:
- Talk To Other Members
- Notification Of Responses To Questions
- Favorite Forums One Click Access
- Keyword Search Of All Posts, And More...
Register now while it's still free!
Already a member? Close this window and log in.
Join Us Close