Detect if MDB has autoexec or a startup form

D

David Pierce

Does anyone know of way to detect if a MDB has a autoexec or startup form in
use without openned the MDB using access.exe.

Many thanks in advance
 
D

Douglas J. Steele

Function StartUp(PathToMDB As String) As String
On Error GoTo EH

Dim db As DAO.Database
Dim strMessage As String
Dim strStartForm As String

If Len(Dir(PathToMDB)) > 0 Then
Set db = OpenDatabase(PathToMDB)
strStartForm = db.Properties("StartUpForm")
If Len(strStartForm) > 0 Then
strMessage = PathToMDB & " specifies " & _
strStartForm & " for startup." & vbCrLf
End If
If db.Containers("Scripts").Documents("AutoExec").Name = "AutoExec" Then
strMessage = strMessage & PathToMDB & _
" includes an AutoExec macro." & vbCrLf
End If
Else
strMessage = PathToMDB & " does not exist."
End If

If Len(strMessage) = 0 Then
strMessage = PathToMDB & " has no startup options specified."
End If

Cleanup:
Set db = Nothing
StartUp = strMessage
Exit Function

EH:
Select Case Err.Number
Case 3170 ' Property does not exist
Resume Next
Case Else
strMessage = "*** ERROR (" & _
Err.Number & ") " & Err.Description
MsgBox strMessage
Resume Cleanup
End Select

End Function
 
J

Jerry Whittle

You can usually start up the database while holding the Shift key. That
bypasses the autoexec and startup forms (unless someone disabled the special
keys). Then you can check for an Autoexce macro or code behind the startup
form.

If you are really worried that a database file may be destructive, put it on
a computer which is not connected to a network. That way only that computer
may need to be rebuilt if the worse happens.

Also if you happen to have Access 2007, you can open up the file and not
enable options whic will keep code from working. Make sure that the file is
NOT in the Trusted zone.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top