Relinking problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cmd@mountain.net

    Relinking problem

    I use the following code (behind a command button on the FE) to relink
    from a user's local copy of the BE to the file-server's BE on our LAN.
    I use this, for example, when a person brings in their laptop and
    connects to our LAN.

    The code works fine if there are no other users accessing the server's
    BE at the time. If the file-server's BE is open at the time, however,
    then the relinking process does not finish -- it just pauses. When
    everyone else closes out of the database, then the process continues on
    its own and the laptop's FE is now linked to the server's BE.

    Our multi-user, split database setup works fine normally --
    simultaneous users can open and close out of the database without a
    problem -- as long as their FEs are already linked to the server's BE.

    One other factor: The FEs have a hidden form, always open, and which is
    based on a utility table in the BE.

    Question:
    Is there anything I can do which will allow computers on our LAN to
    relink from a local BE to the server's BE without having everyone else
    close out of the database?

    Thanks for any help.
    Mark

    Dim dbs As Database
    Dim tdf As TableDef
    Dim Tdfs As TableDefs
    Dim NewPathname As String
    Set dbs = CurrentDb
    Set Tdfs = dbs.TableDefs

    '************** **Link to Network Drive-P

    If Len(Dir("P:\fps data.mdb")) = 0 Then
    MsgBox "You're not connected to the network."
    Resume exithandler
    End If

    NewPathname = "P:\fpsdata.mdb "

    'Loop through the tables collection
    For Each tdf In Tdfs
    On Error GoTo errhandler

    '...link main tables
    If Len(tdf.Connect ) > 0 Then
    tdf.Connect = ";DATABASE= " & NewPathname
    tdf.RefreshLink
    End If
    Next 'Goto next table

  • Anthony England

    #2
    Re: Relinking problem

    <cmd@mountain.n et> wrote in message
    news:1137065676 .161235.186510@ f14g2000cwb.goo glegroups.com.. .[color=blue]
    >I use the following code (behind a command button on the FE) to relink
    > from a user's local copy of the BE to the file-server's BE on our LAN.
    > I use this, for example, when a person brings in their laptop and
    > connects to our LAN.
    >
    > The code works fine if there are no other users accessing the server's
    > BE at the time. If the file-server's BE is open at the time, however,
    > then the relinking process does not finish -- it just pauses. When
    > everyone else closes out of the database, then the process continues on
    > its own and the laptop's FE is now linked to the server's BE.
    >
    > Our multi-user, split database setup works fine normally --
    > simultaneous users can open and close out of the database without a
    > problem -- as long as their FEs are already linked to the server's BE.
    >
    > One other factor: The FEs have a hidden form, always open, and which is
    > based on a utility table in the BE.
    >
    > Question:
    > Is there anything I can do which will allow computers on our LAN to
    > relink from a local BE to the server's BE without having everyone else
    > close out of the database?
    >
    > Thanks for any help.
    > Mark
    >
    > Dim dbs As Database
    > Dim tdf As TableDef
    > Dim Tdfs As TableDefs
    > Dim NewPathname As String
    > Set dbs = CurrentDb
    > Set Tdfs = dbs.TableDefs
    >
    > '************** **Link to Network Drive-P
    >
    > If Len(Dir("P:\fps data.mdb")) = 0 Then
    > MsgBox "You're not connected to the network."
    > Resume exithandler
    > End If
    >
    > NewPathname = "P:\fpsdata.mdb "
    >
    > 'Loop through the tables collection
    > For Each tdf In Tdfs
    > On Error GoTo errhandler
    >
    > '...link main tables
    > If Len(tdf.Connect ) > 0 Then
    > tdf.Connect = ";DATABASE= " & NewPathname
    > tdf.RefreshLink
    > End If
    > Next 'Goto next table[/color]




    This doesn't seem quite right - you should be able to re-link while others
    are connected to the BE. What happens if you re-link your tables to the
    back end, then allow others back in so you are all connected normally. At
    this point, click the button and re-link (it doesn't matter that you were
    already correctly connected, the code should still do the same thing). Does
    this work, or does it hang?

    What you have not explained is when you try and re-link. If you have a
    hidden form which is connected to the back end and is supposed to be always
    loaded, this cannot open if your front end tables are not working. Perhaps
    this is the cause of the hang. If not, post back.


    Comment

    • cmd@mountain.net

      #3
      Re: Relinking problem

      Thanks for responding, Anthony

      (I thought I had posted a response, but I guess not!)

      Anyhow,
      If my FE is already linked to the P-Drive (the server's BE), then I can
      click the re-link button and re-link to the P-Drive as many times as I
      want, regardless of whether other users are in the database. If,
      however, I first re-link to my C-drive's copy of the BE and then try to
      re-link to the P-Drive, the operation will pause/stop if there are
      other users in the database. As soon as they exit the database, my FE
      will complete the re-linking to the P-Drive.

      I'm sorry, but I'm not sure I understand your question/comment
      regarding the hidden form and "this cannot open if your front end
      tables are not working". I'm probably missing something that you're
      asking, but yes, all the tables are in the BE, including the one the
      hidden form is associated with, and true, the form cannot open if the
      FE can't link to the BE.

      Just to be clear regarding "hang" -- the re-linking process will
      complete the re-linking by itself as soon as other users exit the
      database.

      Thank you,
      Mark

      Comment

      • paii, Ron

        #4
        Re: Relinking problem


        <cmd@mountain.n et> wrote in message
        news:1137065676 .161235.186510@ f14g2000cwb.goo glegroups.com.. .[color=blue]
        > I use the following code (behind a command button on the FE) to relink
        > from a user's local copy of the BE to the file-server's BE on our LAN.
        > I use this, for example, when a person brings in their laptop and
        > connects to our LAN.
        >
        > The code works fine if there are no other users accessing the server's
        > BE at the time. If the file-server's BE is open at the time, however,
        > then the relinking process does not finish -- it just pauses. When
        > everyone else closes out of the database, then the process continues on
        > its own and the laptop's FE is now linked to the server's BE.
        >
        > Our multi-user, split database setup works fine normally --
        > simultaneous users can open and close out of the database without a
        > problem -- as long as their FEs are already linked to the server's BE.
        >
        > One other factor: The FEs have a hidden form, always open, and which is
        > based on a utility table in the BE.
        >
        > Question:
        > Is there anything I can do which will allow computers on our LAN to
        > relink from a local BE to the server's BE without having everyone else
        > close out of the database?
        >
        > Thanks for any help.
        > Mark
        >
        > Dim dbs As Database
        > Dim tdf As TableDef
        > Dim Tdfs As TableDefs
        > Dim NewPathname As String
        > Set dbs = CurrentDb
        > Set Tdfs = dbs.TableDefs
        >
        > '************** **Link to Network Drive-P
        >
        > If Len(Dir("P:\fps data.mdb")) = 0 Then
        > MsgBox "You're not connected to the network."
        > Resume exithandler
        > End If
        >
        > NewPathname = "P:\fpsdata.mdb "
        >
        > 'Loop through the tables collection
        > For Each tdf In Tdfs
        > On Error GoTo errhandler
        >
        > '...link main tables
        > If Len(tdf.Connect ) > 0 Then
        > tdf.Connect = ";DATABASE= " & NewPathname
        > tdf.RefreshLink
        > End If
        > Next 'Goto next table
        >[/color]

        You cannot reattach a table that is open. Close all forms and processes with
        open tables before reattaching. You should also close and reopen the FE
        database after reattaching the tables.


        Comment

        • cmd@mountain.net

          #5
          Re: Relinking problem

          Thanks, Ron

          but ... the re-link process seems to work fine if I'm already connected
          to my local copy of the BE and re-link to that same location. Also, it
          works fine if I'm already connected to the server's BE and re-link to
          that location, provided no one else is in the database. In both case,
          the hidden file is open and connected to the respective BE.

          Mark

          Comment

          • cmd@mountain.net

            #6
            Re: Relinking problem

            My bad!
            Sorry, Ron ... I missed seeing a step at the beginning of my code where
            I do, in fact, close the hidden file before going to the re-link step.
            Mark

            Comment

            • cmd@mountain.net

              #7
              Re: Relinking problem

              Ron,

              Any thoughts as to why I can re-link to the server's BE -- even though
              there are other users in the database -- *provided* that my FE was
              linked to that BE prior to me clicking the re-link button? In this
              case, the process doesn't "hang"; but it will if my FE had first been
              linked to my local BE.

              Mark

              Comment

              • cmd@mountain.net

                #8
                Re: Relinking problem

                (talking to myself)
                -- probably because it's not actually re-linking?

                Comment

                • paii, Ron

                  #9
                  Re: Relinking problem


                  <cmd@mountain.n et> wrote in message
                  news:1137089515 .675323.6160@f1 4g2000cwb.googl egroups.com...[color=blue]
                  > Ron,
                  >
                  > Any thoughts as to why I can re-link to the server's BE -- even though
                  > there are other users in the database -- *provided* that my FE was
                  > linked to that BE prior to me clicking the re-link button? In this
                  > case, the process doesn't "hang"; but it will if my FE had first been
                  > linked to my local BE.
                  >
                  > Mark
                  >[/color]

                  Here is a snippet of the code I have been using since 94.
                  Some of it came from Solutions.MDB which was part of Access 2
                  This code deletes the table attachment then creates a new attachment.
                  This may or may not be the problem, but it works from me.

                  CurDB.TableDefs .Delete "Table Name"
                  Set CurTable = CurDB.CreateTab leDef("TableNam e")
                  CurTable.Connec t = ";DATABASE= " & filename

                  CurTable.Source TableName = "Table Name"
                  CurDB.TableDefs .Append CurTable

                  CurTable.Refres hLink


                  Comment

                  • cmd@mountain.net

                    #10
                    Re: Relinking problem

                    Thank you, Ron.
                    I'll give that a try, but I think your initial caution about not being
                    able to re-attach to open tables is correct, and even though it
                    appeared I was doing just that, the database was probably just
                    confirming the links as they had already existed -- and, therefore, not
                    hanging up, or producing an error of some kind.

                    Mark

                    Comment

                    • paii, Ron

                      #11
                      Re: Relinking problem


                      <cmd@mountain.n et> wrote in message
                      news:1137098961 .465651.156430@ g44g2000cwa.goo glegroups.com.. .[color=blue]
                      > Thank you, Ron.
                      > I'll give that a try, but I think your initial caution about not being
                      > able to re-attach to open tables is correct, and even though it
                      > appeared I was doing just that, the database was probably just
                      > confirming the links as they had already existed -- and, therefore, not
                      > hanging up, or producing an error of some kind.
                      >
                      > Mark
                      >[/color]

                      The caution of open tables was only for tables opened by the FE database
                      doing the re-attached. You should be able to attach to the BE while other
                      users have it open, unless someone has it open exclusively.


                      Comment

                      • David W. Fenton

                        #12
                        Re: Relinking problem

                        "paii, Ron" <paii@packairin c.com> wrote in
                        news:FeCdnekqhZ ZmDFveRVn-qw@athenet.net:
                        [color=blue]
                        > You cannot reattach a table that is open. Close all forms and
                        > processes with open tables before reattaching. You should also
                        > close and reopen the FE database after reattaching the tables.[/color]

                        On this latter point, why? I've never done so, ever -- not even once
                        -- and my computer, nor any computer belonging to my clients, has
                        ever exploded or anything.

                        --
                        David W. Fenton http://www.dfenton.com/
                        usenet at dfenton dot com http://www.dfenton.com/DFA/

                        Comment

                        • David W. Fenton

                          #13
                          Re: Relinking problem

                          "paii, Ron" <paii@packairin c.com> wrote in
                          news:go2dnShbNa _xM1veRVn-pA@athenet.net:
                          [color=blue]
                          > Here is a snippet of the code I have been using since 94.
                          > Some of it came from Solutions.MDB which was part of Access 2
                          > This code deletes the table attachment then creates a new
                          > attachment. This may or may not be the problem, but it works from
                          > me.
                          >
                          > CurDB.TableDefs .Delete "Table Name"
                          > Set CurTable = CurDB.CreateTab leDef("TableNam e")
                          > CurTable.Connec t = ";DATABASE= " & filename
                          >
                          > CurTable.Source TableName = "Table Name"
                          > CurDB.TableDefs .Append CurTable
                          >
                          > CurTable.Refres hLink[/color]

                          This can be orders of magnitude slower than updating the connect
                          string. It isn't in all cases, but I've seen it take *MUCH* longer
                          than the former.

                          --
                          David W. Fenton http://www.dfenton.com/
                          usenet at dfenton dot com http://www.dfenton.com/DFA/

                          Comment

                          • cmd@mountain.net

                            #14
                            Re: Relinking problem

                            Ron,

                            Are you saying that as long as the FE first closes all of its open
                            tables, then it should be able to attach to the BE's tables on the
                            server regardless of whether anyone else is in the database (provided
                            they haven't opened it exclusively)?

                            If that's what you're saying, then I guess when my FE is already
                            attached to the BE on the server and I click the re-attach button --
                            which first closes the hidden form -- then the FE does in fact
                            re-attache to all the tables in the server's BE.

                            But, why would the same process "hang" until other users have exited
                            the database in the case where my FE was initially linked to my local
                            BE? The hidden form is still closed first before trying to attach to
                            the server's BE.

                            Mark

                            Comment

                            • paii, Ron

                              #15
                              Re: Relinking problem


                              "David W. Fenton" <XXXusenet@dfen ton.com.invalid > wrote in message
                              news:Xns9749B4F 329CEFf99a49ed1 d0c49c5bbb2@127 .0.0.1...[color=blue]
                              > "paii, Ron" <paii@packairin c.com> wrote in
                              > news:FeCdnekqhZ ZmDFveRVn-qw@athenet.net:
                              >[color=green]
                              > > You cannot reattach a table that is open. Close all forms and
                              > > processes with open tables before reattaching. You should also
                              > > close and reopen the FE database after reattaching the tables.[/color]
                              >
                              > On this latter point, why? I've never done so, ever -- not even once
                              > -- and my computer, nor any computer belonging to my clients, has
                              > ever exploded or anything.
                              >
                              > --
                              > David W. Fenton http://www.dfenton.com/
                              > usenet at dfenton dot com http://www.dfenton.com/DFA/[/color]

                              My reason goes back to the original code and Access 2, which behaved
                              strangely if I didn't reopen the FE. It has works in my environment so I
                              haven't changed the procedure. Also my applications get startup data from
                              the BE, without the restart I would need to call a function to reinitialize
                              the app.

                              I use re-attach to change to a different BE, normally to attach my
                              developmental FE to the production BE before distributing it to the users.


                              Comment

                              Working...