{"id":68793,"date":"2005-10-07T22:18:00","date_gmt":"2005-10-07T22:18:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2005\/10\/07\/how-can-i-determine-which-version-of-access-was-used-to-create-a-database\/"},"modified":"2005-10-07T22:18:00","modified_gmt":"2005-10-07T22:18:00","slug":"how-can-i-determine-which-version-of-access-was-used-to-create-a-database","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-determine-which-version-of-access-was-used-to-create-a-database\/","title":{"rendered":"How Can I Determine Which Version of Access was Used to Create a Database?"},"content":{"rendered":"<p><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\"> \n<P>Hey, Scripting Guy! How can I determine which version of Access was used to create an Access database?<BR><BR>&#8212; TW<\/P><IMG border=\"0\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" height=\"5\"><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\"><A href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><IMG class=\"farGraphic\" title=\"Script Center\" border=\"0\" alt=\"Script Center\" align=\"right\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" width=\"120\" height=\"288\"><\/A> \n<P>Hey, TW. You know, at least one of the Scripting Guys is a bit old-fashioned, to say the least. He doesn\u2019t own a cell phone, and he won\u2019t use drive-through windows. He wears his baseball hat forwards rather than backwards (!), and he absolutely <I>refuses<\/I> to buy books online.<\/P>\n<P>That last one is particularly shocking: any time he wants a new book, he <I>goes to a bookstore to buy it!<\/I> (It <I>is<\/I> hard to believe that people still live that way, isn\u2019t it?) But that\u2019s because this Scripting Guy is a firm believer in serendipity, in the art of accidental discovery. He likes \u201cbrick-and-mortar\u201d bookstores because, while wandering through the aisles, he might suddenly discover a really cool book, a book he would never have found online. (And, no, not even with all those new-fangled computer programs that can alert you to the fact that a book exactly like the last 30 books you bought has just been published.)<\/P>\n<P>As it turns out, serendipity can be useful in scripting as well. When we first received this email, we immediately turned to the Microsoft Access documentation, figuring this would be an easy problem to solve. Unfortunately, though, we couldn\u2019t find anything having to do with versioning. And so we set this question aside, chalking it up as one of those things that you\u2019d think <I>would<\/I> be scriptable, but isn\u2019t.<\/P>\n<P>But then serendipity entered the picture. While looking up something else in the Access documentation (which we couldn\u2019t find either; maybe we just don\u2019t know how to <I>use<\/I> documentation) we ran across a property named <B>FileFormat<\/B>. You guessed it: <B>FileFormat<\/B> (rather than, say, Version) is the property that tells us which version of Access was used to create a database. Want to know which version of Access was used to create the database C:\\Scripts\\Test.mdb? Here you go:<\/P><PRE class=\"codeSample\">Set objAccess = CreateObject(&#8220;Access.Application&#8221;)\nobjAccess.OpenCurrentDatabase &#8220;C:\\Scripts\\Test.mdb&#8221;<\/p>\n<p>intFormat = objAccess.CurrentProject.FileFormat<\/p>\n<p>Select Case intFormat\n    Case 2 Wscript.Echo &#8220;Microsoft Access 2&#8221; \n    Case 7 Wscript.Echo &#8220;Microsoft Access 95&#8221;\n    Case 8 Wscript.Echo &#8220;Microsoft Access 97&#8221; \n    Case 9 Wscript.Echo &#8220;Microsoft Access 2000&#8221;\n    Case 10 Wscript.Echo &#8220;Microsoft Access 2003&#8221;\nEnd Select\n<\/PRE>\n<TABLE id=\"EVD\" class=\"dataTable\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\">By default, Access will present you with a dialog box asking if you <I>really<\/I> want to open the database. To bypass that warning, set your macro security level to <B>Low<\/B>.<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV>\n<P>We begin by creating an instance of the <B>Access.Application<\/B> object, then we use the <B>OpenCurrentDatabase<\/B> method to open the file C:\\Scripts\\Test.mdb. (As you can see, the path is the sole parameter we pass to OpenCurrentDatabase.) We then use this line of code to get the value of the <B>FileFormat<\/B> property (which, technically, is a property of the <B>CurrentProject<\/B> object) and store that value in a variable named intFormat:<\/P><PRE class=\"codeSample\">intFormat = objAccess.CurrentProject.FileFormat\n<\/PRE>\n<P>All that\u2019s left now is to set up a <B>Select Case<\/B> statement to examine the value of intFormat and echo back the corresponding version of Microsoft Access. For example, suppose intFormat is equal to 9. In that case, this line of code will be triggered and \u201cMicrosoft Access 2000\u201d will be returned as the version of the application that created the database:<\/P><PRE class=\"codeSample\">Case 9 Wscript.Echo &#8220;Microsoft Access 2000&#8221;\n<\/PRE>\n<P>We\u2019d like to see you find an answer like that online!<\/P>\n<P>Oh, right: if you\u2019re reading this column then we guess you <I>did<\/I> find the answer online, didn\u2019t you? Hmmm \u2026.<\/P>\n<P>By the way, you might have noticed that we started an instance of Access but then never specifically <I>quit<\/I> that instance. Does that mean we have an orphaned copy of Microsoft Access running on our computer? No. As it turns out, Access works a bit different from Word or Excel: when you instantiate Access within a script, that instance will terminate at the same time the script does. There\u2019s a way to work around that if need be, but that\u2019s a topic we\u2019ll have to address some other time.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! How can I determine which version of Access was used to create an Access database?&#8212; TW Hey, TW. You know, at least one of the Scripting Guys is a bit old-fashioned, to say the least. He doesn\u2019t own a cell phone, and he won\u2019t use drive-through windows. He wears his baseball hat [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[717,54,49,3,5],"class_list":["post-68793","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-access-application","tag-microsoft-access","tag-office","tag-scripting-guy","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! How can I determine which version of Access was used to create an Access database?&#8212; TW Hey, TW. You know, at least one of the Scripting Guys is a bit old-fashioned, to say the least. He doesn\u2019t own a cell phone, and he won\u2019t use drive-through windows. He wears his baseball hat [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/68793","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=68793"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/68793\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=68793"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=68793"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=68793"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}