[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to know if it is a valid .mdb file with DAO

Posted on 2005-05-06
3
Medium Priority
?
184 Views
Last Modified: 2010-05-02


Hi,

I want to give an error if the user tried to open an invalid .mdb file.

For example, a user can rename a word file "example.doc" to "example.mdb"

However this is not a real .mdb file. How can my application dectects it?


Thanks!
0
Comment
Question by:TungVan
  • 2
3 Comments
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 200 total points
ID: 13949346
Try opening it.  If it fails, you know it is invalid.
0
 
LVL 1

Accepted Solution

by:
jgarth earned 800 total points
ID: 13962983
(LOL acperkins statement)
Maybe this is a little more closer to what you are looking for.

Private Sub Form_Load()

On Error GoTo errPrc

'Your code to open the Database
'
'

Exit Sub
errPrc:
   If Err.Number = -2147467259 Or Err.Number = 5 Then  'err=5 is if no path,  other is bad mdb
        MsgBox "AN ERROR HAS OCCURED WHILE TRYING TO CONNECT TO  DATABASE!"
   End if
End Sub
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 13963008
>>Maybe this is a little more closer to what you are looking for.<<
Actually that is exactly what I had in mind.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question