473,396 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 20884
NeoPa
32,556 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,834 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,834 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,556 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,556 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,556 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,556 Expert Mod 16PB
Hands up anyone who's never made such an error. No takers? No. I thought not.
Sep 23 '17 #13
isladogs
455 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, 345 views)
Sep 5 '22 #14
isladogs
455 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.
Sep 7 '22 #15
NeoPa
32,556 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.
Sep 8 '22 #16

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

Similar topics

4
by: Howard | last post by:
I am trying to use DoCmd.TranferSpreadsheet to import a spreadsheet into an Access table that's not the CurrentDB. I have the database open, but I don't see how to tell the TransferSpreadsheet...
5
by: Vladislav Moltchanov | last post by:
I am making data entry tool in Acc2K for several data collecting centres. It is convenient to have several files (mde file, .mdb with tables only etc) located in the same directory. To make...
4
by: polux | last post by:
Hi everyone, i'm getting lost here... used to work with Access97 now Access2002 I'm having trouble finding currentdb Following references are checked: vb for applications
1
by: jnikle | last post by:
I have a parameter query named "qry_employee_info_reports" that I need to run in the OnOpen event of a form. I'm after its total number of records. The query's got several joins in it, and one of...
7
by: Tony M. | last post by:
I'm trying to execute an append query. I have a case that works, and one that returns an object not set error. THIS WORKS: Private Sub cmdArchiveRecs_Click() BeginTrans CurrentDb.Execute...
3
by: Richard Hollenbeck | last post by:
In DAO, is there any difference between "set db = CurrentDb()" with parentheses and "set db = CurrentDb" without parentheses? I'm just looking for data from a single field in a table inside the...
1
by: sphinney | last post by:
As my Access form opens, I want it to find the names of the tables in the current Access database and populate a combobox with the table (recordset) names. Problem is, the CurrentDb.Recordsets...
1
MitchR
by: MitchR | last post by:
Hello Folks; I have run myself into a hole I cannot get of and need some assistance. I have a Form "Frm_ATandT_Activation_Center" that has a sub form "Frm_ATandT_Activation"....
7
by: realspido1 | last post by:
Hi all, I have a problem which I can't figure out what is it caused by and how to solve it as I never expericed it before even though I've been using same approach many times before. I have front...
6
TheSmileyCoder
by: TheSmileyCoder | last post by:
I am trying to use the CurrentDB.Recordsaffected property to ensure that the latest CurrentDB.Execute actually affected some records. I have a function intented to backup a record into a history...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.