|
-
Jun 17th, 2009, 03:59 AM
#1
Thread Starter
Lively Member
Access Report
Hi everybody
I am trying to get a report of ms access database(mdb database).
code Code:
Private cn As ADODB.Connection
Private Sub Command1_Click()
Dim cn As New ADODB.Connection
Dim acc As Object
Set acc = CreateObject("Access.Application")
Dim strDbName As String
strDbName = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source =" & App.Path & "\Pharmacy OP Ver 1.0.0.mdb "
acc.OpenCurrentDatabase strDbName
acc.DoCmd.OpenReport RptstaffDed, acViewPreview
End Sub
I am trying to connect it, but there is an error that comes
"Microsoft Access can't open the database because it is missing or opened exclusively by another user, or it is not an ADP file.
Can somebody point out my mistakes
Please Help
-
Jun 30th, 2009, 10:39 AM
#2
Fanatic Member
Re: Access Report
Reread the error message...
I would say that you need to close all instances of the DB. even if it's not visible... so goto Taskmanager and end the msaccess process.
-
Jun 30th, 2009, 11:18 AM
#3
Re: Access Report
You are trying to use ADO specific code against the Access Automation Server.
The first argument to the OpenCurrentDatabase method is simply the path to the database. Don't specify Provider.
The Provider is only required when you are connecting to a database thru ADO.
Dim strDbName As String
strDbName = App.Path & "\Pharmacy OP Ver 1.0.0.mdb "
acc.OpenCurrentDatabase strDbName
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|