Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Accessing File Error Message When Trying to Compile Database Code

Status
Not open for further replies.

zerocul

Programmer
Sep 9, 2002
18
US
During the process of adding new forms to my existing Access database, something has happened to the database file. While in VBA adding code for controls, etc., when I select the Debug pulldown menu and select Compile from the menu I receive the following error..."Error Accessing File. Network Connection May Have Been Lost." Need help. I am not on a network, nor am I accessing other files across a network. All files I am accessing are contained within a single directory on my local hard drive. What has happened and how due I fix this problem. Thanks in advance...
 
You're gonna have to get a back up of your DB and restore it.

Or, you can make a new DB and copy all of the objects from the corrupt one, but this method only works every now and then, you may get the same message while copying the objects.

When ever you copy any form, report or module that has code in it from one DB to another, compilethe DB immediately.. If you close the DB without complining first, the symptopms you wrote about will present themselves.

Tyrone Lumley
augerinn@gte.net


 
I got same error when using vbaunit on Excel, and word and access, except Visio. This is because not all of the reference files are properly ready for use when the vba file opened, if more than 4 references are specified.
The way to escape the error is to execute next proc each time when i opened the file.
I always submit this proc by hand, because the file fails to open if called in initial proc such as workbook_open on some windows os.

Sub ResetReferences()
Dim ref As vbide.Reference
Dim refs As vbide.References
Dim myFullPath As String
Set refs = Application.VBE.ActiveVBProject.References
For Each ref In refs
With ref
If .Name = "MSForms" Then
myFullPath = .FullPath
refs.Remove ref
refs.AddFromFile (myFullPath)
End If
End With
Next
End Sub


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top