Multi User issue?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shaun Harwood

    Multi User issue?

    Hello all

    I have a problem - and being a little new to Access - it seems like a
    nightmare to figure out.
    Here is the Prob.
    I have a Database which consists of a bunch of Tables. Now I have an
    application which is running on the same PC which is testing an electronic
    device and at the end of the test it opens up a database connection and adds
    the test results to one of the tables (table depends on the device being
    tested). All this works fine unless I have the database open and I am using
    a form to examine data in the tables. The Test Software returns the
    following..

    ActiveX Object "DAO Workspace" returned error code 0x800a0d1c(3356 )
    Attempting to open a Database that is already open

    I am not opening the database exclusively when I am looking at the forms.

    Here is the code I am using in my Test Software which is returning the error

    Set db = createObject("D AO.DBEngine.36" ).OpenDatabase( "MyDatabase.mdb ",
    TRUE, FALSE)
    Set rst = db.OpenRecordSe t("My Table", dbOpenDynaset)
    rst.AddNew

    ** I set the Fields here **

    rst.Update
    rst.Close
    db.Close

    The error is returned from the first line which tries to open the database.

    I would like to know

    1. Can I have an application open a database connection while I am looking
    at it
    2. If I can - the am I going about this the wrong way

    Any help will be gratefully received
    Incidently - the test software is Agilents HP Vee running using the
    Microsoft DAO 3.6 Object Library

    Thanks

    Shaun H


  • MGFoster

    #2
    Re: Multi User issue?

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Instead of using CreateObject() use GetObject(). GetObject() will set a
    ref to the existing instance of the Access application, if there is one.
    If there isn't an instance, use an error catch & then use
    CreateObject().

    From the Access Help article on GetObject Function:

    "Note Use the GetObject function when there is a current instance of
    the object or if you want to create the object with a file already
    loaded. If there is no current instance, and you don't want the object
    started with a file loaded, use the CreateObject function.

    If an object has registered itself as a single-instance object, only one
    instance of the object is created, no matter how many times CreateObject
    is executed. With a single-instance object, GetObject always returns the
    same instance when called with the zero-length string ("") syntax, and
    it causes an error if the pathname argument is omitted. You can't use
    GetObject to obtain a reference to a class created with Visual Basic."

    See the VBA example in the GetObject Function article.

    --
    MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
    Oakland, CA (USA)

    -----BEGIN PGP SIGNATURE-----
    Version: PGP for Personal Privacy 5.0
    Charset: noconv

    iQA/AwUBQaA7moechKq OuFEgEQLYTACgnh rgvg/ooytU5RrHZ9vLvl d+yycAnj0J
    p8wXQahXOFJ+skt ax8xqKQ4N
    =Segb
    -----END PGP SIGNATURE-----


    Shaun Harwood wrote:[color=blue]
    > Hello all
    >
    > I have a problem - and being a little new to Access - it seems like a
    > nightmare to figure out.
    > Here is the Prob.
    > I have a Database which consists of a bunch of Tables. Now I have an
    > application which is running on the same PC which is testing an electronic
    > device and at the end of the test it opens up a database connection and adds
    > the test results to one of the tables (table depends on the device being
    > tested). All this works fine unless I have the database open and I am using
    > a form to examine data in the tables. The Test Software returns the
    > following..
    >
    > ActiveX Object "DAO Workspace" returned error code 0x800a0d1c(3356 )
    > Attempting to open a Database that is already open
    >
    > I am not opening the database exclusively when I am looking at the forms.
    >
    > Here is the code I am using in my Test Software which is returning the error
    >
    > Set db = createObject("D AO.DBEngine.36" ).OpenDatabase( "MyDatabase.mdb ",
    > TRUE, FALSE)
    > Set rst = db.OpenRecordSe t("My Table", dbOpenDynaset)
    > rst.AddNew
    >
    > ** I set the Fields here **
    >
    > rst.Update
    > rst.Close
    > db.Close
    >
    > The error is returned from the first line which tries to open the database.
    >
    > I would like to know
    >
    > 1. Can I have an application open a database connection while I am looking
    > at it
    > 2. If I can - the am I going about this the wrong way
    >
    > Any help will be gratefully received
    > Incidently - the test software is Agilents HP Vee running using the
    > Microsoft DAO 3.6 Object Library[/color]

    Comment

    • Forrest

      #3
      Re: Multi User issue?

      > Set db = createObject("D AO.DBEngine.36" ).OpenDatabase( "MyDatabase.mdb ",[color=blue]
      > TRUE, FALSE)[/color]

      What do the true & false mean? Does your program want ex access to
      the file?
      [color=blue]
      > 1. Can I have an application open a database connection while I am looking
      > at it[/color]

      Absolutely. As long as you're not locking the table ( say changing
      its design ), you can both share the databasse. Especially if your
      app is adding new records instead of changing existing ones.

      What happens if you have the forms open, and launch a new Access
      window?

      Comment

      Working...