471,321 Members | 1,686 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,321 software developers and data experts.

CurrentDb.Properties("MDE")

PhilOfWalton
1,430 Expert 1GB
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.

15 17208
NeoPa
32,405 Expert Mod 16PB
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
1,430 Expert 1GB
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
8,826 Expert 8TB
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
1,430 Expert 1GB
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
8,826 Expert 8TB
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
32,405 Expert Mod 16PB
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
1,430 Expert 1GB
What version and date of MSO.DLL are you using?
Thanks

Phil
Sep 20 '17 #8
NeoPa
32,405 Expert Mod 16PB
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
1,430 Expert 1GB
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
32,405 Expert Mod 16PB
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
1,430 Expert 1GB
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
32,405 Expert Mod 16PB
Hands up anyone who's never made such an error. No takers? No. I thought not.
Sep 23 '17 #13
isladogs
384 Expert Mod 256MB
I realise this thread is 5 years old but an interesting thing happened today when I was testing a bug reported at another forum.

Bear with me whilst I explain:
The bug in Access 365 v2207 was that using a wizard (query/form or report) on a table with an MVF or attachment field caused Access to hang then crash. Creating any of those objects manually worked without issue

As I wrote in that thread I was tempted to say this is yet another good reason to avoid both MVFs and attachment fields,
However, more helpfully, I reported the issue to the Access team this afternoon.

The bug is actually fixed in v2208 (released a few hours later) ...though replaced by a new bug!

The point relevant to this thread is that testing the bug somehow created the MDE property & set it to T as in an ACCDE file
As a result I had typical ACCDE functionality (restricted menus ; unable to export / import objects etc)
However, it was still an ACCDB file & the code was still viewable



Luckily I was able to restore ACCDB functionality as the MDE property was NOT read only in this case

All very weird!
Attached Images
File Type: jpg AccessBug.jpg (151.9 KB, 49 views)
3 Weeks Ago #14
isladogs
384 Expert Mod 256MB
Apologies for posting a link to another forum.
I've since written an article about this strange occurrence: Oops...how did that make an ACCDE file?
A member of the Access team has now offered to investigate the cause.
2 Weeks Ago #15
NeoPa
32,405 Expert Mod 16PB
I've been noticing (some of) the work you've been doing Colin. It doesn't fail to impress :-) Keep driving forward as you are doing.
2 Weeks Ago #16

Post your reply

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

Similar topics

5 posts views Thread by Vladislav Moltchanov | last post: by
4 posts views Thread by polux | last post: by
3 posts views Thread by Richard Hollenbeck | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.