[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 433
  • Last Modified:

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
0
jforbes
Asked:
jforbes
1 Solution
 
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 new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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
 
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

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now