'check for existance of database

On Wed, 04 Jun 1997 22:21:08 GMT, gherrera@earthlink.net wrote:

>I'm trying to wrap the OpenDatabase function with some code that will
>detect invalid paths, etc.  My finished function might be called
>something like NewOpenDatabase and would take the same parameters.
>I can't seem to get my function to return an object and I've got a
>hunch that it simply isn't possible in VB.  Could you please confirm
>this?  I'd really appreciate it.

I always use the next code to check the existence of a database:

Public Function CheckDatabase() As Boolean
    Dim db As Database
    On Error GoTo fout_check_database
    Set db = OpenDatabase(DBNaam$)
    CheckDatabase = True
    Exit Function
    MsgBox CStr(Err) & ": " & Error, MB_ICONEXCLAMATION, Titel$
    CheckDatabase = False

End Function

'on the main form
    DBNaam$ = App.Path & "\data\" & dbName$
    'check database
    If Not CheckDatabase Then
        MsgBox "Start making the database...", MB_ICONEXCLAMATION, Titel$
        'call proc to make the database
        'you can also show here a drive/dir/list box to let the user
        'choose his/her own location!
        Call MaakDatabase
    End If
    Set db = OpenDatabase(DBNaam)