473,654 Members | 3,033 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Determine and MDB file's Access version without opening it?

Me
Hi all,
I have an Access application that has to import hundreds of other
MDB's, some access 97 and some 2000, and merge them into several large
mdb's. so far so good, but my command:

Set appAccess = GetObject(Targe tDBPathNAme, "Access.Applica tion.9")

sometimes fails, of course, when the MDB to be imported is Access 97
type.

How do I determine in advance (before GetObject) what version a closed
(unaccessed) MDB is created with?

the best I have come up with, shamefully, was to use "On error"
detection
like this:
<the beginning of the import loop>

OpenImportConne ction = true
Set appAccess = GetObject(Targe tDBPathNAme, "Access.Applica tion.9")
OpenImportConne ction = false
< the error handling section >
If (Err.Number = 7866 Or InStr(1, Err.Description , "Microsoft Access
can't open the database because it is missing") > 0) And
OpenImportConne ction Then

' probably trying to open an Access 97 file as an Access 2000 version,
' so switch importing to version 97

Set appAccess = Nothing
Set appAccess = GetObject(Targe tDBPathNAme,
"Access.Applica tion.8")
Resume Next

End If

(I got two types of error mesasges occuring because of this).

is there anything better than this, that doesn't depend on
errorhandling?
Thanks for reading.

hh.
Nov 13 '05 #1
1 24066

"Me" <he****@lycos.c om> wrote in message
news:2d******** *************** ***@posting.goo gle.com...
Hi all,
I have an Access application that has to import hundreds of other
MDB's, some access 97 and some 2000, and merge them into several large
mdb's. so far so good, but my command:

Set appAccess = GetObject(Targe tDBPathNAme, "Access.Applica tion.9")

sometimes fails, of course, when the MDB to be imported is Access 97
type.

How do I determine in advance (before GetObject) what version a closed
(unaccessed) MDB is created with?

the best I have come up with, shamefully, was to use "On error"
detection
like this:
<the beginning of the import loop>

OpenImportConne ction = true
Set appAccess = GetObject(Targe tDBPathNAme, "Access.Applica tion.9")
OpenImportConne ction = false
< the error handling section >
If (Err.Number = 7866 Or InStr(1, Err.Description , "Microsoft Access
can't open the database because it is missing") > 0) And
OpenImportConne ction Then

' probably trying to open an Access 97 file as an Access 2000 version,
' so switch importing to version 97

Set appAccess = Nothing
Set appAccess = GetObject(Targe tDBPathNAme,
"Access.Applica tion.8")
Resume Next

End If

(I got two types of error mesasges occuring because of this).

is there anything better than this, that doesn't depend on
errorhandling?
Thanks for reading.

hh.


Function FindVersion(str DbPath As String) As String
Dim dbs As Database
Dim strVersion As String
Const conPropertyNotF ound As Integer = 3270

On Error GoTo Err_FindVersion

' Open the database and return a reference to it.
Set dbs = OpenDatabase(st rDbPath)

' Check the value of the AccessVersion property.
strVersion = dbs.Properties( "AccessVersion" )

Debug.Print strVersion
' Return the two leftmost digits of the value of
' the AccessVersion property.
strVersion = Left(strVersion , 2)

' Based on the value of the AccessVersion property,
' return a string indicating the version of Microsoft Access
' used to create or open the database.
Select Case strVersion
Case "02"
FindVersion = "2.0"
Case "06"
FindVersion = "95"
Case "07"
FindVersion = "97"
Case "08"
FindVersion = "2000"
Case "09"
FindVersion = "2002"
End Select

Exit_FindVersio n:
On Error Resume Next
dbs.Close
Set dbs = Nothing
Exit Function

Err_FindVersion :
If Err.Number = conPropertyNotF ound Then
MsgBox "This database hasn't previously been opened " & _
"with Microsoft Access."
Else
MsgBox "Error: " & Err & vbCrLf & Err.Description
End If
Resume Exit_FindVersio n
End Function




Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1633
by: balgach | last post by:
Greetings all, I have a group of rather large files (by group i mean close to 2x10^7 files, each 12-15megs) now i need information which is stored in just the last 512 bytes of each file. i was wondering if there is a way to strip out this information without loading the entire file into memory. Right now im doing it with fopen() and fread() and it takes several hours to process all the files. obviously i know exactly where the...
8
10315
by: Francisco | last post by:
Hi, How can I use a MS-Access DB in a computer without Access installed? I read something about a "runtime" utility, but I don't know how to use it. Any help? Thanks
3
2539
by: Ken Hall | last post by:
Is it possible to create an Excel spreadsheet using VB.NET without opening the Excel application or having to have the Excel application on the operating computer? KH
8
1639
by: G .Net | last post by:
Hi How can I find which version of Access is installed on a computer from within a vb.net application? G
3
3188
dima69
by: dima69 | last post by:
Hi all. I use a following code to run a procedure in another application: Dim App as Access.Application set App = CreateObject("C:\MyApp.mde") App.Run "MyProc" ... The problem is that when using CreateObject I cannot determine which version of Access will be started for App. So if my main application supports Access2K2, and the user has Access2K installed (in addition to Access2K2), CreateObject may return Access2K application - even if...
6
20445
by: Filips Benoit | last post by:
Dear All, All 3 codes, copied from internet, triggers error 429 : ActiveX component can't create object ! No compile error. I have the reference set to Adobe Acrobat 7.0 Type Library I do not have the full version of Adobe Reader 7.0 ! The final goal is to print a PDF-file from access after selecting the file in a browser.
6
4579
by: =?Utf-8?B?UGF1bA==?= | last post by:
I am getting an "Access to the path "xxxx" is denied error. I believe is because the file that I am writing to programatically is being read/written to by another end user. These files have the same file name and must have the same file name. I am essentially overwrite an existing file that is being used by another user. My question: Is there some method or property in the IO class that will allow me to CHECK to see if it is safe to...
2
2949
by: Samdaye | last post by:
I am trying to print a PDF file directly from Access. There are hundreds of PDFs that are in a folder, where i know the path, and the file name is determined from the data that I pull back in access. Is there a way to print this file directly from access. I can open then file using the hyperlink, but I can't figure out how to print it without opening the file and then getting the user to click the print button. Any help would be...
1
1587
by: djpaul | last post by:
Hello, I am just a newbie to javascript, but the most stuff i do is in php or .net. But, now i have 2 buttons on my script that are calling a javascript function as shown below (OnClick""). Now after a person pushes 1 of the 2 buttons, i want to send some information to a php-file to update my database. The only thing that the customer will see is a message from the alert( "Thanks"); for example. This is what i did now: <script...
0
8372
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8285
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8475
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4293
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2709
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1915
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1592
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.