Accessing an Access DB using VB

I have been having problems accessing a relational Access 97 DB, on a computer that does not contain Access.  My installation installs all of the DAO support files, but the user does not have access rights to Access the DB.  I receive a 3051 Cannot open Jet Database, Already Open Exclusivly, or not proper user rights to view data.  How can I allow the data to be viewed without having the user install Access 97 to fix the problem.


Here is a snippet of the function I use to link to the DB.

Private Sub DBOpen(ByVal ExclusiveFlag As Boolean)
   ' This procedure will return a Nothing db handle if
   ' exclusive use is requested but cannot be obtained.
   On Error GoTo ErrProc
   
   DBEngine.DefaultUser = "Admin"
   DBEngine.DefaultPassword = ""
   
   Set ws = CreateWorkspace("", "Admin", "", dbUseJet)
   Set db = Nothing
   'If Not ExclusiveFlag Then
    '  DBOnFloppy
   'End If
   Set db = ws.OpenDatabase(Param.DBPath, ExclusiveFlag)
   'Set db = OpenDatabase(Param.DBPath + BSLASH + DBNAME, ExclusiveFlag)
         
         If Not (TypeName(db) = "Nothing") Then
            Set Param.qd = db.QueryDefs("QParameters")  ' ugly but faster
         End If
   Exit Sub
   
ErrProc:
   If Err.Number = 3356 And ExclusiveFlag Then  ' cannot open exclusive
      MsgBox "Another user is currently using the database.  " + Chr$(13) _
           + "You must close all other programs using the database  " + Chr$(13) _
           + "before you can execute this command.  ", vbInformation
      Resume Next
   Else
      If Err.Number = 3356 And Not ExclusiveFlag Then
         Err.Number = 9102
      End If
      If Err.Number = 3055 Then
         Exit Sub
      Else
         ErrObj.Abort "DBObj.DBOpen"
      End If
   End If
End Sub
Thank you in advance.

-John M. Forbes
LVL 1
jforbesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jforbesAuthor Commented:
Edited text of question.
0
loayCommented:
There are another way you can do your job by
1- create an module and put all the global variables on it (Databases,Recordset ).
2- make an sub called it (main)
3- let this sub as start up prodedure
4- use your definitions by using Addnew Or Edit properies

i hope that will help you
if not send to me back
0
jforbesAuthor Commented:
Thank you loay,
  I am afraid you maybe don't understand, I am usin AddNew and Edit that is not the problem, my code works great when Access has been installed, because Access creates a user Handle Admin, when I take the DB to a machine without Access the Admin user has not been created or associated on that machine, and that is when it crashes.  If you happen to have anymore ideas, I would be greatful.

Thank You,
-John
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Jon_RaymondCommented:
You should specify the workgroup database using DBEngine.SystemDB =
0
jforbesAuthor Commented:
I tried your DBEngine.SystemDB command and there was no change.  The problem still exists.  Any more Ideas

-John
0
jforbesAuthor Commented:
Adjusted points to 150
0
TDragonCommented:
  Set db = ws.OpenDatabase(Param.DBPath, ExclusiveFlag)
   'Set db = OpenDatabase(Param.DBPath + BSLASH + DBNAME, ExclusiveFlag)

I assume by these two lines that the DBNAME is now included in DBPATH, if not that would be a problem, my assumption is probably correct because you said this app does work on PCs that have Access.

You may want to look at the MS Knowledge Base Articles: Q165009 and Q132143

Hopefully they might help.

Q: What happens when you use the CreateDatabase method to create a database on the system without Access (adding a bogus table and fields for testing)?

Unrelated to your question, but some other suggestions:
LINE: If Not (TypeName(db) = "Nothing") Then
could also be
LINE: If Not db is Nothing Then

And of course, since you use constants other places:
chr(13)
could also be
vbCr or vbCrLf
vbCrLf actually being chr(13)&chr(10)

Hope this helps.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jforbesAuthor Commented:
The MS Knowledge Base Helped, but I found my problem out, I needed to install the system.mbw on the client machine.

Thanks to all.

-John
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.