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:
  1. Dim bln1ExclusiveMode As Boolean
  2.     Dim bln1ReadOnly As Boolean
  3. '
  4. '   Declare workspace and open database
  5. '
  6.     bln1ExclusiveMode = True
  7.     bln1ReadOnly = False
  8.     str3Database = App.Path & "\Sam.mdb"
  9.     Set wsp3workspace = DBEngine.Workspaces(0)
  10.     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:
  1. Private Sub ReportBorrowed()
  2.  
  3. Dim AccessDB As Access.Application
  4. Dim strFilter As String
  5. Dim strWhere As String
  6.  
  7.  
  8.     Set AccessDB = New Access.Application
  9.     AccessDB.OpenCurrentDatabase App.Path & "\Sam.mdb"
  10.     AccessDB.DoCmd.OpenReport "Borrowed", acViewNormal, strFilter, strWhere
  11.     AccessDB.Visible = True
  12.     AccessDB.Quit acQuitSaveAll
  13.     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