A real ACCDB ?

  • Thread starter javiernews via AccessMonster.com
  • Start date
J

javiernews via AccessMonster.com

Hi,

I use this code in orther to know if is a real MDB

Public Function funIsMDE(ByRef WritePath As String) As Boolean

Const cMDE As String = "T"
Dim dbs As DAO.Database

Set dbs = DBEngine.OpenDatabase(WritePath, True, False)

On Error Resume Next

If Err = 0 And cMDE Then
funIsMDE = True
Else
funIsMDE = False
End If

dbs.Close
Set dbs = Nothing

End Function

But it does not work for Access 2007 in ACCDB or ACCDE format

How to know if is a real ACCDB ?

Thank you
 
C

Clifford Bass

Hi,

I do not see how that would ever work. The "On Error Resume Next" will
always clear out the error number. And what is that "And cMDE" part? Using
a string as a boolean? Maybe it needs to be compared to something? You
could try this instead:

Function funIsMDE(ByRef WritePath As String) As Boolean

Dim dbs As DAO.Database

On Error Resume Next

Set dbs = DBEngine.OpenDatabase(WritePath, True, False)
If Err.Number = 0 Then
funIsMDE = True
dbs.Close
Set dbs = Nothing
Else
Err.Clear
funIsMDE = False
End If

End Function

Hope that helps,

Clifford Bass
 
C

Chris O'C via AccessMonster.com

Sorry, your code won't tell you if it's an mdb or accdb in every version of
Access, not just in 2007.

This code should work for you in any version of Access:

Public Function testIsMDB()
On Error GoTo Proc_Err

Dim db As Database

Set db = OpenDatabase("c:\test\db.accdb")
Debug.Print Not(IsMDE(db))
Proc_Exit:
Set db = Nothing
Exit Function
Proc_Err:
MsgBox Err.Number & vbCrLf & Err.Description
Err.Clear
Resume Proc_Exit
End Function

Public Function IsMDE(db As Database) As Boolean
On Error Resume Next
Dim strMDE As String
strMDE = db.Properties("MDE")
IsMDE = (Err.Number = 0 And strMDE = "T")
End Function


Chris
 
C

Chris O'C via AccessMonster.com

Sorry, your code won't tell you if it's an mdb or accdb either. It needs to
check for the MDE database property.

Chris
 
J

javiernews via AccessMonster.com

Thank Chis O'C you for the code now is detecting good either for as MDE and
ACCDE format
 
C

Clifford Bass

Hi Chris,

No problem. I figured there needed to be something more--hence my
questions--I just was not sure what.

Clifford Bass
 

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