Trying not to open a database exclusively.
Hi
I have been trying to print ot a report in Acess from VB. I havew worked out the code to do this, but I have already opened the database up in my project & so I get an error about the database being opened exclusively already by another user.
This might be because in opening the database at the start of the program I have used
VB Code:
Dim bln1ExclusiveMode As Boolean
Dim bln1ReadOnly As Boolean
'
' Declare workspace and open database
'
bln1ExclusiveMode = True
bln1ReadOnly = False
str3Database = App.Path & "\Sam.mdb"
Set wsp3workspace = DBEngine.Workspaces(0)
Set dba3Database = wsp3workspace.OpenDatabase(str3Database, bln1ExclusiveMode, bln1ReadOnly)
to cut down on any problems with many people opening up the database. The problem is that when I call the report I use the code:
VB Code:
Private Sub ReportBorrowed()
Dim AccessDB As Access.Application
Dim strFilter As String
Dim strWhere As String
Set AccessDB = New Access.Application
AccessDB.OpenCurrentDatabase App.Path & "\Sam.mdb"
AccessDB.DoCmd.OpenReport "Borrowed", acViewNormal, strFilter, strWhere
AccessDB.Visible = True
AccessDB.Quit acQuitSaveAll
Set AccessDB = Nothing
which causes the problem. I am trying to combat this but have drawn a blank with the methods I've used so far.Could anyone suggest how to:
a) open the database in a mode that isn't exclusive
or
b) get the repots to use the same connection to the database that I made on opening the program.
Thanks
Sam