What is the scope of global variables in a shared front-end database?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • beacon
    Contributor
    • Aug 2007
    • 579

    What is the scope of global variables in a shared front-end database?

    Hi everybody,

    [Access 2003]

    I have a front-end database with a login form. When a user opens the database the login form loads at startup. When the user has entered his/her ID and password correctly, I store the user's name in a global variable that I add to tables to show who has updated the records.

    I just implemented this yesterday, but I have a question that I didn't think to ask until now. If more than one user accesses the front-end, will the global variable be unique to the instance of the front-end that the user opens or will the variable change for each subsequent user that logs in?

    So, if user A logs in and the global variable is set to "User A" and user B log in right after, will the global variable change to "User B" or will it stay "User A" in an instance of the front-end for user A and stay "User B" in an instance of the front-end for user B?

    Thanks,
    beacon
  • Lysander
    Recognized Expert Contributor
    • Apr 2007
    • 344

    #2
    If each user has there own copy of the front end, on there own PC, then the global variable will be unique to each user. i.e. what you want it to be.

    Since I can't see how two users can access the same frontend on the same pc at the same time, (after all, that is the whole point of having front and back ends) you don't have a problem

    Comment

    • Lysander
      Recognized Expert Contributor
      • Apr 2007
      • 344

      #3
      Ack, my mistake, did not read the title correctly. You say you have a 'shared' front end. How is this shared? Is the mdb on a server with multiple users accessing it at the same time?

      Comment

      • beacon
        Contributor
        • Aug 2007
        • 579

        #4
        Sorry Lysander, I didn't provide enough info. The users are accessing a front-end .mde. The front-end is on a network drive and the users access it using a shortcut to the .mde.

        Comment

        • Lysander
          Recognized Expert Contributor
          • Apr 2007
          • 344

          #5
          Okay, if your database is split into a front end and a back end, then put a copy of each front end on each users PC and there is no problem.

          As your users are accessing a front end that is on a network drive, I am not sure what would happen, I have never tried that.

          Let me try to open two instances of one of my databases on the same front end, on the same PC and see what happens.

          Okay, it works. I set a global variable to Mark on one instance and Dana on the other and both retained their values, but, I really would recommend putting the front end MDE on each PC. Apart from anything else, it will greatly improve the performance in loading forms etc.

          Comment

          • beacon
            Contributor
            • Aug 2007
            • 579

            #6
            The database isn't overly large and there are only 15 or so people that use it, so performance isn't really an issue.

            Thanks for testing that out. I would have done it, but I thought I would pose the question to see if anyone knew when, or if, the global variables would be reset if the same .mde was accessed by multiple people.

            I guess, since the global variable is initiated on the front-end .mde instead of the back-end, the variable should be maintained throughout use of the front-end. At least, that's what I'm hoping for and the original reason for my question.

            Thanks,
            beacon

            Comment

            • Stewart Ross
              Recognized Expert Moderator Specialist
              • Feb 2008
              • 2545

              #7
              Hi all. The front-end application is loaded locally on the user's PC, regardless of the file's location (whether on a network drive or on the user's PC itself). Global variables are allocated in local memory only and cannot be shared between machines, or indeed between multiple instances of the same database running on the same PC (as each runs in its own local memory space).

              -Stewart

              Comment

              • beacon
                Contributor
                • Aug 2007
                • 579

                #8
                Thanks Lysander and Stewart.

                I marked Lysander's answer as the best answer because it actually proved what I was trying to find out, although Stewart's answer explained what is actually happening with the variables. Too bad I can't mark them both as the best answer...

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32633

                  #9
                  Originally posted by Beacon
                  Beacon:
                  will the global variable be unique to the instance of the front-end that the user opens or will the variable change for each subsequent user that logs in?
                  Essentially you're right on the button in that it is relative to the session, or instance the user is working with. The answers already given are both correct of course. I just wanted to clarify in the terms you yourself used in your OP.

                  Your conundrum about who to assign Best Answer to is also quite understandable. As far as we are concerned (if I may speak for my respected colleagues), as long as you assign it to a correct answer in a fair way, as you clearly have, then we all understand that there can only be one post that is so assigned, and are happy that a correct one has been at least. There are many threads with perfectly good answers that never get a post assigned at all. In as much as it matters at all to the individual expert, we all appreciate that a minority of correct answers get marked anyway. What I suppose I'm saying, in a somewhat roundabout way is, don't worry about it. We all appreciate that you've at least assigned a decent answer to your thread from those available :-)

                  Comment

                  Working...