Lost Modules - Possible corrupt DLL (1 Viewer)

Clepto

Registered User.
Local time
Today, 00:45
Joined
May 12, 2012
Messages
35
Are you importing the objects one at a time to narrow down which one is causing the issue?

Yes. I am importing them via the import wizard, one at a time, but I get the error message with every one I try.

I have imported a module from an earlier version and it works fine. it also appears in the navigation pane in the VBA window, which the original modules do not, although they are still there in the Access window.( I do have backups, but I have done a lot of work on a couple of modules and that was a month or two ago and I don’t want to have to get my head around it again, but it is looking like I will have to.)

I was searching the whole project for the occurrence of a query and I am wondering if I have unwittingly erased all the code?
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 19:45
Joined
Jan 23, 2006
Messages
15,379
You may find this older code from Arvin Meyer helpful. Uncomment and change file specs to suit your issue.

Code:
Public Sub DocDatabase()
 '====================================================================
 ' Name:    DocDatabase
 ' Purpose: Documents the database to a series of text files
 '
 ' Author:  Arvin Meyer
 ' Date:    June 02, 1999
 ' Comment: Uses the undocumented [Application.SaveAsText] syntax
 '          To reload use the syntax [Application.LoadFromText]
 '      Modified to set a reference to DAO 8/22/2005
 '====================================================================
On Error GoTo Err_DocDatabase
Dim dbs As DAO.Database
Dim cnt As DAO.Container
Dim doc As DAO.Document
Dim i As Integer

Set dbs = CurrentDb() ' use CurrentDb() to refresh Collections
'
'Set cnt = dbs.Containers("Forms")
'For Each doc In cnt.Documents
'    Application.SaveAsText acForm, doc.name, "D:\Document\" & doc.name & ".txt"
'Next doc
'
'Set cnt = dbs.Containers("Reports")
'For Each doc In cnt.Documents
'    Application.SaveAsText acReport, doc.name, "D:\Document\" & doc.name & ".txt"
'Next doc
'
'Set cnt = dbs.Containers("Scripts")
'For Each doc In cnt.Documents
'    Application.SaveAsText acMacro, doc.name, "D:\Document\" & doc.name & ".txt"
'Next doc

Set cnt = dbs.Containers("Modules")
For Each doc In cnt.Documents
    Application.SaveAsText acModule, doc.name, "c:\users\mellon\Documents\ModuleSources\" & doc.name & ".txt"
    Debug.Print "Saved  " & doc.name
Next doc

For i = 0 To dbs.QueryDefs.Count - 1
    Application.SaveAsText acQuery, dbs.QueryDefs(i).name, "D:\Document\" & dbs.QueryDefs(i).name & ".txt"
Next i

Set doc = Nothing
Set cnt = Nothing
Set dbs = Nothing

Exit_DocDatabase:
    Exit Sub


Err_DocDatabase:
    Select Case Err

    Case Else
        MsgBox Err.Description
        Resume Exit_DocDatabase
    End Select

End Sub
 

Clepto

Registered User.
Local time
Today, 00:45
Joined
May 12, 2012
Messages
35
You may find this older code from Arvin Meyer helpful. Uncomment and change file specs to suit your issue.

Code:
Public Sub DocDatabase()
 '====================================================================
 ' Name:    DocDatabase
 ' Purpose: Documents the database to a series of text files
 '
 ' Author:  Arvin Meyer
 ' Date:    June 02, 1999
 ' Comment: Uses the undocumented [Application.SaveAsText] syntax
 '          To reload use the syntax [Application.LoadFromText]
 '      Modified to set a reference to DAO 8/22/2005
 '====================================================================
On Error GoTo Err_DocDatabase
Dim dbs As DAO.Database
Dim cnt As DAO.Container
Dim doc As DAO.Document
Dim i As Integer

Set dbs = CurrentDb() ' use CurrentDb() to refresh Collections
'
'Set cnt = dbs.Containers("Forms")
'For Each doc In cnt.Documents
'    Application.SaveAsText acForm, doc.name, "D:\Document\" & doc.name & ".txt"
'Next doc
'
'Set cnt = dbs.Containers("Reports")
'For Each doc In cnt.Documents
'    Application.SaveAsText acReport, doc.name, "D:\Document\" & doc.name & ".txt"
'Next doc
'
'Set cnt = dbs.Containers("Scripts")
'For Each doc In cnt.Documents
'    Application.SaveAsText acMacro, doc.name, "D:\Document\" & doc.name & ".txt"
'Next doc

Set cnt = dbs.Containers("Modules")
For Each doc In cnt.Documents
    Application.SaveAsText acModule, doc.name, "c:\users\mellon\Documents\ModuleSources\" & doc.name & ".txt"
    Debug.Print "Saved  " & doc.name
Next doc

For i = 0 To dbs.QueryDefs.Count - 1
    Application.SaveAsText acQuery, dbs.QueryDefs(i).name, "D:\Document\" & dbs.QueryDefs(i).name & ".txt"
Next i

Set doc = Nothing
Set cnt = Nothing
Set dbs = Nothing

Exit_DocDatabase:
    Exit Sub


Err_DocDatabase:
    Select Case Err

    Case Else
        MsgBox Err.Description
        Resume Exit_DocDatabase
    End Select

End Sub
Thank you so much for the code.

I have run it, as is, in the corrupted database and I get: “Compile error User-defined type not defined” on line “Dim dbs As DAO.Database” Strange? Could this be diagnostic?

In an uncorrupted database I get “Reserved error”

I presume that this is because: “c:\users\mellon\Documents\ModuleSources\” refers to a location on the writer's computer, where there is a folder: ModuleSources where each doc.name is located, but I can’t find ModuleSources on my computer. I am running Access 2013 on Windows 7.

I have created an empty folder U:\Users\User\Documents\Recovery\
Does this replace the D:\Document\ location in the code?

Many Thanks
 

speakers_86

Registered User.
Local time
Yesterday, 19:45
Joined
May 17, 2007
Messages
1,919
Both of those paths you need to change to a folder on your hard drive. It doesn't make any difference where you save them as long as you can navigate there.
 

speakers_86

Registered User.
Local time
Yesterday, 19:45
Joined
May 17, 2007
Messages
1,919
Regarding the user type not defined error, this makes me wonder about your references. Take a look and see if anything is out of order with those. Sorry for double posting, but I can't edit records on this computer...
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 19:45
Joined
Jan 23, 2006
Messages
15,379
THE c:\users\mellon\Documents\ModuleSources\... refers explicitly to my PC. As I said in the original post
Uncomment and change file specs to suit your issue
.
You have to create a folder, or use an existing folder on your PC. File specs have to relate to existing files on your PC.

As was mentioned, you must make sure you do not have missing references. Go to your code window and look in Tools->References (look for MISSING...)
Good luck.
 

Clepto

Registered User.
Local time
Today, 00:45
Joined
May 12, 2012
Messages
35
Both of those paths you need to change to a folder on your hard drive. It doesn't make any difference where you save them as long as you can navigate there.


I have created the empty folders U:\Users\User\Documents\Recovery\
&
U:\Users\User\Documents\Recoverytxt\

The section of code now reads as follows:

Set cnt = dbs.Containers("Modules")
For Each doc In cnt.Documents
Application.SaveAsText acModule, doc.Name, "folder U:\Users\User\Documents\Recovery\" & doc.Name & ".txt"
Debug.Print "Saved " & doc.Name
Next doc

For i = 0 To dbs.QueryDefs.Count - 1
Application.SaveAsText acQuery, dbs.QueryDefs(i).Name, "folder U:\Users\User\Documents\Recoverytxt\" & dbs.QueryDefs(i).Name & ".txt"
Next i

I still get “Reserved error” with no number on running it in an uncorrupted database and “Compile error User-defined type not defined” on the line “Dim dbs As DAO.Database” in the corrupted one, so for some reason it won’t even initiate a database.

I tried to rewrite the Dim statement and see if the telescense (If that is the right word) worked, it did until I got to the As in the statement, then when I pressed “D” the only option that appeared was Date. The Databese, Databases etc options were not available as options. Have you any idea what this may mean?
 

Clepto

Registered User.
Local time
Today, 00:45
Joined
May 12, 2012
Messages
35
Have you tried a decompile? I usually follow David W Fenton's advice from this thread: http://stackoverflow.com/questions/...ecompile-and-recompile-a-database-application



On decompile, I have modified the file paths as follows:

Function Decompile-AccessDB{
param ([string]$dbFileName)

[string]$argument = '"' + $dbFileName + '"' + "/Decompile"
Start-Process -FilePath C:\ProgramFiles\MicrosoftOffice15\Data\Delta\root\office15\MSACCESS.EXE' -ArgumentList $argument}


Decompile-AccessDB -Path "U:\Users\User\My Documents\Corrupted.accdb"

However I am unfamiliar with Powershell. I have never heard of this before.

Do I set up a Decompile database and set these two sections of code up as two different modules?

I am running Access 2013 on Widows 7 does this make a difference?

 

speakers_86

Registered User.
Local time
Yesterday, 19:45
Joined
May 17, 2007
Messages
1,919
Did you look at the references? Make sure none of them are missing.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:45
Joined
May 7, 2009
Messages
19,231
decompile your db if that will help.
 

speakers_86

Registered User.
Local time
Yesterday, 19:45
Joined
May 17, 2007
Messages
1,919
Regarding the powershell thing, you're looking at the wrong post in that thread.
 

Clepto

Registered User.
Local time
Today, 00:45
Joined
May 12, 2012
Messages
35
decompile your db if that will help.

I would but for some reason the run command does not accept the file path:
C:\Program Files\Microsoft Office 15\root\office15\msaccess.exe/decompile

I get “Windows cannot find ‘C:\Program’ ....

I don’t know how else to write it.
I take it that you give the path to the application?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:45
Joined
May 7, 2009
Messages
19,231
easiest way is to create a new desktop shortcut. point to where msaccess is. then at the end of the command line place /decompile.
 

Clepto

Registered User.
Local time
Today, 00:45
Joined
May 12, 2012
Messages
35
easiest way is to create a new desktop shortcut. point to where msaccess is. then at the end of the command line place /decompile.

If I create a shortcut "C:\Program Files\Microsoft Office 15\root\office15\msaccess.exe/decompile" windows immediately changes the forward slash before decompile to a backslash as follows:
"C:\Program Files\Microsoft Office5\root\office15\msaccess.exe\decompile" and produces a message that the file cannot be found. Am I making a syntax error?

I am currently trying to find a vba function to decompile the database
 

Clepto

Registered User.
Local time
Today, 00:45
Joined
May 12, 2012
Messages
35
If your database isn't to big (max. 2MB) then zip it and post it here.
Else create a new database a import one module at a time.

I have just got the following to run through Start>Run "C:\Program Files\Microsoft Office 15\root\office15\msaccess.exe" "U:\Users\Corrupted.accdb" /decompile

The database opens but when I try to open a module I still get the message”XYZ refers to a module that does not exist.” The decompile command did work because the compile option was available under Debug, but it made no difference. So I have to rewrite the module. At least I have learnt how to decompile.

Many thanks to all those who responded to my thread.

Best regards

Clepto
 

Clepto

Registered User.
Local time
Today, 00:45
Joined
May 12, 2012
Messages
35
If I create a shortcut "C:\Program Files\Microsoft Office 15\root\office15\msaccess.exe/decompile" windows immediately changes the forward slash before decompile to a backslash as follows:
"C:\Program Files\Microsoft Office5\root\office15\msaccess.exe\decompile" and produces a message that the file cannot be found. Am I making a syntax error?

I am currently trying to find a vba function to decompile the database

I have just got the following to run through Start>Run "C:\Program Files\Microsoft Office 15\root\office15\msaccess.exe" "U:\Users\Corrupted.accdb" /decompile

The database opens but when I try to open a module I still get the message”XYZ refers to a module that does not exist.” The decompile command did work because the compile option was available under Debug, but it made no difference. So I have to rewrite the module. At least I have learnt how to decompile.

Many thanks to all those who responded to my thread.

Best regards

Clepto
 

Clepto

Registered User.
Local time
Today, 00:45
Joined
May 12, 2012
Messages
35
Are you able to open a form in design view? Or can't you open the database at all?
Without hands on the database it is difficult to help.
By the way, did you try a "Compact & Repair"?


I have just got the following to run through Start>Run "C:\Program Files\Microsoft Office 15\root\office15\msaccess.exe" "U:\Users\Corrupted.accdb" /decompile

The database opens but when I try to open a module I still get the message”XYZ refers to a module that does not exist.” The decompile command did work because the compile option was available under Debug, but it made no difference. So I have to rewrite the module. At least I have learnt how to decompile.

Many thanks to all those who responded to my thread.

Best regards

Clepto
 

Clepto

Registered User.
Local time
Today, 00:45
Joined
May 12, 2012
Messages
35
Just for clarity, are you talking about custom modules (functions and procedures) OR Class Objects (the code that runs from form event - OnClick, AfteUpdate etc) OR Both?

I ask because your use of the word "Modules" in the OP would imply the custom modules as would the fact they are visible in the side bar (navigation pane) BUT your comment about "text box with an after update event procedure" would suggest ClassObjects.


I have just got the following to run through Start>Run "C:\Program Files\Microsoft Office 15\root\office15\msaccess.exe" "U:\Users\Corrupted.accdb" /decompile

The database opens but when I try to open a module I still get the message”XYZ refers to a module that does not exist.” The decompile command did work because the compile option was available under Debug, but it made no difference. So I have to rewrite the module. At least I have learnt how to decompile.

Many thanks to all those who responded to my thread.

Best regards

Clepto
 

Clepto

Registered User.
Local time
Today, 00:45
Joined
May 12, 2012
Messages
35
Regarding the user type not defined error, this makes me wonder about your references. Take a look and see if anything is out of order with those. Sorry for double posting, but I can't edit records on this computer...


I have just got the following to run through Start>Run "C:\Program Files\Microsoft Office 15\root\office15\msaccess.exe" "U:\Users\Corrupted.accdb" /decompile

The database opens but when I try to open a module I still get the message”XYZ refers to a module that does not exist.” The decompile command did work because the compile option was available under Debug, but it made no difference. So I have to rewrite the module. At least I have learnt how to decompile.

Many thanks to all those who responded to my thread.

Best regards

Clepto
 

Users who are viewing this thread

Top Bottom