first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

VB: ADO; Code; Connecting to an Access .MDB File

Public Function basDataConnection(Optional CloseConn = False) As Boolean

On Error GoTo basDataConnection_Err

If VBA.VarType(CloseConn) <> vbBoolean Then VBA.Err.Raise 450

If CloseConn Then
    If Not m_cnnADO Is Nothing Then
        m_cnnADO.Close
        Set m_cnnADO = Nothing
    End If
    GoTo basDataConnection_Exit
End If

basDataConnection = basFileExists(App.Path & c_dbName)
If Not basDataConnection Then VBA.Err.Raise 76

Set m_cnnADO = New ADODB.Connection
With m_cnnADO
    .Open _
    ConnectionString:="Provider=Microsoft.Jet.OLEDB.3.51;" _
        & "Persist Security Info=False;" _
        & "User ID=Admin;" _
        & "Data Source=" & VB.App.Path & "\\DSAPL.mdb;" _
        & "Mode=Share Deny None;" _
        & "Extended Properties="";" _
        & "COUNTRY=0;" _
        & "CP=1252;" _
        & "LANGID=0x0409"";" _
        & "Locale Identifier=1033;" _
        & "Jet OLEDB:System database="""";" _
        & "Jet OLEDB:Registry Path="""";" _
        & "Jet OLEDB:Database Password="""";" _
        & "Jet OLEDB:Global Partial Bulk Ops=2"
    .CursorLocation = adUseClient
End With

basDataConnection_Exit: Exit Function

basDataConnection_Err: Select Case Err Case 76 'Path not found MsgBox "The Application Table file " & c_dbName & " cannot be found.", vbCritical basDataConnection = False Resume basDataConnection_Exit Case Else MsgBox Err & ": " & Err.Description, vbCritical, "basDataConnection Error" basDataConnection = False Resume basDataConnection_Exit End Select

End Function

mod date: 1999-03-01T21:35:15.000Z