By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,488 Members | 2,552 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,488 IT Pros & Developers. It's quick & easy.

CurrentDb.Properties("MDE")

PhilOfWalton
Expert 100+
P: 1,430
I have a number of DBs that check to see if the database is an AccDb / Mdb or Accde / Mde

A function uses
Expand|Select|Wrap|Line Numbers
  1. CurrentDb.Properties("MDE")
  2.  
to return the value. This has worked for years and years.
Suddenly I am getting an error that the property is not found.

AFIK it used to be in the DAO 3.6 library but is now in the Microsoft Office 14.0 Access Database engine object library. I have a reference to the latter, but if I try to add DAO 3.6, I get a Name conflicts with existing project or library.

Have MS in their wisdom, recently changed th Office 14.0 Access Database engine object library?

Has anyone else had this problem?

Interestingly, I have a AccDe version of a database that has never been touched, and that works OK

Phil
Sep 20 '17 #1

✓ answered by ADezii

Sorry for missing the point, Phil. I was thinking along the lines that if a given DB is not a *.mde or *.accde then the *.MDE Property doesn't even exist and will always generate Error 3270.

Share this Question
Share on Google+
12 Replies


NeoPa
Expert Mod 15k+
P: 31,186
I really don't know Phil.

In order to avoid the error though, you could use an intermediate function procedure that returns some default value when a property doesn't exist. EG. GetProperty().

I use a module for all such stuff. My GetProperty() function will default to using the result from CurrentDb() if no object is specified.

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Const conNoProp As Integer = 3270
  5. Private Const conVBToDB As String = "\2|3\3|4\4|6\5|7\6|5" & _
  6.                                     "\7|8\8|10\11|1\14|20\17|2"
  7.  
  8. 'SetProperty() requires that either intPType is set explicitly OR that
  9. '              varPVal has a valid value if a new property is to be created.
  10. Public Sub SetProperty(strPName As String _
  11.                      , varPVal As Variant _
  12.                      , Optional ByVal objVar As Object _
  13.                      , Optional intPType As Integer = -1)
  14.     Dim prpVal As DAO.Property
  15.  
  16.     Call SetObj(objVar)
  17.     If PropertyExists(strPName, objVar) Then
  18.         objVar.Properties(strPName) = varPVal
  19.     Else
  20.         If intPType = -1 Then intPType = DBVal(varType(varPVal))
  21.         Set prpVal = objVar.CreateProperty(strPName, intPType, varPVal)
  22.         Call objVar.Properties.Append(prpVal)
  23.     End If
  24. End Sub
  25.  
  26. 'GetProperty() returns the value of the specified property if found.
  27. Public Function GetProperty(ByRef strPName As String, _
  28.                             Optional ByVal objVar As Object) As Variant
  29.     Call SetObj(objVar)
  30.     GetProperty = Null
  31.     If PropertyExists(strPName, objVar) Then _
  32.         GetProperty = objVar.Properties(strPName)
  33. End Function
  34.  
  35. 'PropertyExists() returns True if the property exists and False if it doesn't.
  36. Public Function PropertyExists(ByRef strPName As String _
  37.                              , Optional ByVal objVar As Object) As Boolean
  38.     Dim varTest As Variant
  39.  
  40.     On Error GoTo ErrorHandler
  41.     Call SetObj(objVar)
  42.     PropertyExists = True
  43.     varTest = objVar.Properties(strPName)
  44.     Exit Function
  45.  
  46. ErrorHandler:
  47.     If Err <> conNoProp Then
  48.         On Error GoTo 0
  49.         Resume
  50.     End If
  51.     PropertyExists = False
  52. End Function
  53.  
  54. 'DelProperty() deletes the property if it exists.
  55. Public Sub DelProperty(ByRef strPName As String _
  56.                      , Optional ByVal objVar As Object)
  57.     Call SetObj(objVar)
  58.     If Not PropertyExists(strPName, objVar) Then Exit Sub
  59.     Call objVar.Properties.Delete(strPName)
  60. End Sub
  61.  
  62. 'SetObj() sets objVar to CurrentDb() if it's not already set.
  63. Private Sub SetObj(ByRef objVar As Object)
  64.     If objVar Is Nothing Then Set objVar = CurrentDb()
  65. End Sub
  66.  
  67. 'DBVal() returns the value of the Type that is used in DAO
  68. '  from the VBA equivalent.
  69. Private Function DBVal(intVBVal) As Integer
  70.     Dim intX As Integer
  71.  
  72.     intX = InStr(1, conVBToDB, "\" & intVBVal & "|")
  73.     DBVal = Val(Mid(conVBToDB, intX + Len(intVBVal) + 2))
  74. End Function
Sep 20 '17 #2

PhilOfWalton
Expert 100+
P: 1,430
Thanks for that, I use something similar myself to add properties, but my understanding is that MDE property is something that is built into the Access database library.

Does it work for you, and which version of the Microsoft Office 14.0 Access Database engine object library are you using?
Mine is version 14.0.7188.5002 modified 4th September 2017, which is about the time my problems started.

It is in C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE14\MSO.DLL.

I would be pleased to hear if anyone else has this version and if so, if they print
Expand|Select|Wrap|Line Numbers
  1. Print CurrentDb.Properties("MDE")
  2.  
what results they get. Even more interesting is if someone with an earlier version tries the code.


Many thanks,

Phil
Sep 20 '17 #3

ADezii
Expert 5K+
P: 8,597
It is my understanding that if CurrentDB.Properties("MDE") does NOT return the Value of 'T' the DB does NOT contain editable Source Code, thus a *.mde, *.accde. If the Error of 3270 is generated (Property not found), the Database contains editable Source Code and is NOT a *.mde, *.accde.
Expand|Select|Wrap|Line Numbers
  1. Public Function fHasSourceCode()
  2. On Error Resume Next
  3.  
  4. fHasSourceCode = (CurrentDb.Properties("MDE") <> "T")
  5.  
  6. 'Property Not Found
  7. If Err.Number = 3270 Then fHasSourceCode = True
  8.  
  9. On Error GoTo 0
  10. End Function
  11.  
Sep 20 '17 #4

PhilOfWalton
Expert 100+
P: 1,430
Thanks, ADezii, but I think you are missing the point.

On typing Print CurrentDb.Properties("MDE") in the debug window, I get Error 3270 Property not found, so I can't find it's value.

As I said this has worked for years until a few weeks ago when it appears that a new version of Microsoft Office 14.0 Access Database engine object library was installed automatically.

Thanks

Phil
Sep 20 '17 #5

ADezii
Expert 5K+
P: 8,597
Sorry for missing the point, Phil. I was thinking along the lines that if a given DB is not a *.mde or *.accde then the *.MDE Property doesn't even exist and will always generate Error 3270.
Sep 20 '17 #6

NeoPa
Expert Mod 15k+
P: 31,186
There are some properties that always exist though ADezii. I have to say I was new to this one so I tried it on a 2003 install and that also reported "Property doesn't exist", as does my Access 2010 application.
Sep 20 '17 #7

PhilOfWalton
Expert 100+
P: 1,430
What version and date of MSO.DLL are you using?
Thanks

Phil
Sep 20 '17 #8

NeoPa
Expert Mod 15k+
P: 31,186
As I say, I tested it on two separate systems (One with Microsoft DAO 3.6 Object Library set and the other with Microsoft Office 14.0 Access database engine Object Library set). Having said that, how would I even go about checking which version of MSO.DLL is in use - if at all? You know the files that are associated with each of the libraries listed nearly all get truncated so you can't actually see what relates to what. I know this is fixed in the latest version (2016) but 2010 & 2003 are not that.
Sep 21 '17 #9

PhilOfWalton
Expert 100+
P: 1,430
Hi

Use File Explorer to Go to the location mentioned earlier, right click on the MSO.DLL and on the details tab, you see the version & date.

I read somewhere that the MDE property moved fro DAO 3.6 to the MSO.DLL. I had assumed this was correct, but Culpa Mia that was wrong information. The correct file is ACEDAO.DLL which was last modified in December 2015, so that doesn't sound as if it is the problem.

Sorry to have misled everybody.

I have tried to de-register the ACEDAO.Dll but get an error that it was loaded, but the entry point DllUnregisterServer was not found

Cheers

Phil
Sep 21 '17 #10

NeoPa
Expert Mod 15k+
P: 31,186
PhilOfWalton:
Use File Explorer to Go to the location mentioned earlier, right click on the MSO.DLL and on the details tab, you see the version & date.
That's fine for some versions, but doesn't exist on my 2003 setup. Even if it exists how can I be sure it's the one in use. Never mind. I guess it's moot now so not worth pursuing.
Sep 22 '17 #11

PhilOfWalton
Expert 100+
P: 1,430
I don't want you to all fall about laughing, but ... if you must.

The solution to the problem was that I had Break on All Errors set as the error trapping option in the editor options.
An Accdb doesn't have the property CurrentDb.Properties("MDE") so throws an Error 3270.

Really sorry for wasting so much of your time

Grovelling apologies

Phil
Sep 23 '17 #12

NeoPa
Expert Mod 15k+
P: 31,186
Hands up anyone who's never made such an error. No takers? No. I thought not.
Sep 23 '17 #13

Post your reply

Sign in to post your reply or Sign up for a free account.