Single user access...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PSorensen
    New Member
    • Mar 2007
    • 4

    Single user access...

    Hi

    Is there someone who know an easy way, so only one user can access a MS Access db without using users/groups in the database? It should be done by only knowing that someone is logged in/or opening the database?

    I have made a part of a solution with a little login-screen and you only provide your initials and when click "Login" and when I execute the following sql:

    strSQL = "Insert into login_info (Login,CurrentU ser, loggedIn) Values ('" + Txt_login.Value + "','" + FindUser.fOSUse rName + "',1);"

    CurrentDb.execu te strSQL

    But before a user can login to the application I have to check if there is already one user who have the flag "LoggedIn" set to 1 (Yes).
    After the User is finished using the application there should be an update statement where the flag "LoggedIn" is set to 0...

    I have two problems/questions:
    1) How do I make the check for the flag... I'm new to MS Access and have read a lot, but I can't really find a way to open the recordset with the sql (select * from login_info where LoggedIn = 1) and check the field "LoggedIn" in some If... then... else sentense...

    2) Is there some other way to make a MS Access database work in single user mode? Maybe some way to set some kind of isolation level to the database or table access... ex. writing some code in the private sub form_open(Cance l as Integer)...?

    The most important in my application is that only one user can log in and write to the application and all other user should have a message that someone else is editing...


    Regards
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    Have a look in the Tools menu for Options. Under the advanced tab set the Default Open Mode to Exclusive rather than shared. This means once a user is on the database other users can only open it as a Read Only file.

    Mary

    Comment

    • PSorensen
      New Member
      • Mar 2007
      • 4

      #3
      :o) Thanks, it should do it - must have missed it when I was looking...

      Comment

      • MMcCarthy
        Recognized Expert MVP
        • Aug 2006
        • 14387

        #4
        Originally posted by PSorensen
        :o) Thanks, it should do it - must have missed it when I was looking...
        No problem.

        Comment

        • PSorensen
          New Member
          • Mar 2007
          • 4

          #5
          Oh, I was maybe a little too fast...

          Now i've tested on 5 different PC's with different users logged on. I have discovered that the exclusive flag is not set by default but is something set per installation. It's the same with the flags under Tool-->options-->view...

          I need a way to get single user access to the database or tables in the database for every user / PC that opens the database regardlees of the installation or usersetup....

          Is it possible to set those parameters when I open a form?
          (Couldn't find them in help...)

          Comment

          • MMcCarthy
            Recognized Expert MVP
            • Aug 2006
            • 14387

            #6
            Are you distributing the frontends as mde files?

            Comment

            • PSorensen
              New Member
              • Mar 2007
              • 4

              #7
              Originally posted by mmccarthy
              Are you distributing the frontends as mde files?
              No, I have only a single mdb-file... Is it only possible to make exclusive access when I separate the frontend?

              Comment

              • MMcCarthy
                Recognized Expert MVP
                • Aug 2006
                • 14387

                #8
                Originally posted by PSorensen
                No, I have only a single mdb-file... Is it only possible to make exclusive access when I separate the frontend?
                Standard practice would be to separate the frontend and backend. Then you only need to set the options on the backend and can have multiple frontends.

                Mary

                Comment

                Working...