-
Hi,
I am trying to open Access database by using Data Control of VB.
I set the path name under the property (DatabaseName) of the Data Control.
When i try to run it, i am getting error as following:
"Unrecognized database format 'C:\----' "
I don't understand why i am getting this error.
Please help me !
Thank you.
-
<?>
Code:
'open database and set database and recordset
Option Explicit
Public Db as database, Rs as recordset
Public cDName As String
Public cTblName as String
Public Sub OpenDB()
Dim AppPath$
If Right(App.Path, 1) <> "\" Then _
AppPath = App.Path & "\" _
Else AppPath = App.Path
cDBName = AppPath & "YourDatabaseName.mdb"
cTblName = "YourTableName"
Data1.DatabaseName = cDBName
Data1.RecordSource = cTblName
End Sub
Private Sub Form_Load()
'
Call OpenDB
'
Set db = Workspaces(0).OpenDatabase(cDBName)
Set rs = db.OpenRecordset(cTblName)
End Sub