Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Alocin is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jun 2020
    Posts
    15

    Lightbulb How to prevent users opening a form that is already in use

    Hello everyone!
    I am having trouble with too many users opening the same form and making updates.


    I cannot figure out how to prevent other users opening a form that is in use already, and have a message box letting them know to try back later.

    Any help on this simple to many of you but difficult for me to make it work.

    thank you
    Ciao!
    Alocin

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,552
    You check if is is loaded or not with the IsLoaded() function.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870

  4. #4
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,421
    If each user has their own front end that won't work. AFAIK, even if one front end or worse, one unsplit db is being shared each user has opened an instance of Access and that still won't work.

    Not sure why this should be a problem unless the locks setting is incorrect for the situation. I think more info is needed about the db setup and sharing and its usage.
    If a lot of users are looking at records but not doing anything with them, then in those cases, opening the forms based on record snapshots may help.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Alocin is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jun 2020
    Posts
    15
    Thank you. Yes it is a BE and FE.

  6. #6
    Alocin is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jun 2020
    Posts
    15
    I tried using this IsLoaded() (see snippets below) and I just get the msgbox saying the form is open but does not stop it from opening it. What am I doing wrong?

    Code:
    Private Sub Form_Load()
    
        If CurrentProject.AllForms("frmtblplayers").IsLoaded = True Then
            MsgBox "The form is already open. Try back later", vbExclamation, "Form Open Later"
            'Cancel = True
            DoCmd.Close
            
        ElseIf CurrentProject.AllForms("frmtblplayers").IsLoaded = False Then
        DoCmd.OpenForm "frmtblplayers"
        
        End If
    End Sub
    thanks

  7. #7
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,740
    Try
    Docmd.close acform, me.name

    instead of Docmd.close


    However, If each user has a copy of the DB FE, I don't see how this would help. The code only checks its own FE for the loaded form, not any of the others.
    Last edited by davegri; 02-28-2023 at 09:06 PM. Reason: sp

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,552
    Sorry, my view of the initial post was that users were opening multiple copies of a form in their own FE?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Multiple users and multiple frontends should be able to open same form and edit records because, really, it's not the same form.

    I never encountered issue of 'too many users'. Why would this cause issue in your system?

    I have even tested two users opening same unsplit db and working with "same" form without issue. Yes, I know, bad, but it's what they wanted. It was a very simple db with no code.
    Last edited by June7; 03-01-2023 at 03:17 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,928
    OP only said 'Thank you. Yes it is a BE and FE.' They have not clarified that each user has their own copy of the FE on their local device. If they are all using the same FE on a shared folder, that is likely to produce the error, not to mention irrecoverable corruption at some point.

    I doubt the snippet in post #6 would work if the load event is in the form in question - if it's running the load event then it is already loaded so the isloaded will always return true. I would have thought the code would need to be in a button click event or whatever is used for the user to open the form.

  11. #11
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Alocin,
    Please confirm:
    Each user has their own copy of the FE on their individual PC as CJ has mentioned in #10.

  12. #12
    Alocin is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jun 2020
    Posts
    15
    Everyone, my apologies that I was not clear. There is only a single FE using multiple five BE. I have tried also placing the IsLoaded snippet on a button On Click and it too came back with the msgbox that form is loaded but didn't stop others from opening it.

  13. #13
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,928
    This
    There is only a single FE using multiple five BE
    does not answer this
    Please confirm:
    Each user has their own copy of the FE on their individual PC as CJ has mentioned in #10.
    But sounds like there is only one FE and multiple users are using it. If this is the case, then that is a recipe for disaster as suggested in post #10

  14. #14
    Join Date
    Apr 2017
    Posts
    1,792
    Every user MUST have his/her own Front-End - situated either in HD in his/her computer, or on network resource is same LAN as his/her LAN. BE's the FE's are linked to must be on network resource(s) in same LAN. In case user works with app from remote location, the user must remotely log in to Terminal Server in same LAN where FE and BE(s) are stored on network resource(s) available for this user, and run his/her FE from there.

    Different users can have Front-Ends of same design (essentially copies of same FE), or FE's of entirely different design (eg. storage managers, relationship managers and accountants work with same database, but have different FE's).

    Any FE can be linked to any number of BE databases.

    BE DB tables and saved queries/views, the FE is using, are linked to FE (all changes made to linked tables are saved in BE). It also is possible to have additional tables directly in FE, but those will be available only to user working with this FE. Such tables can be used for providing user-based settings, or as temporary tables to store some data during active session - but mostly there is no need for them.

  15. #15
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,421
    I've never heard of anyone using multiple BE's. How on earth would you sync them?
    BE DB tables and saved queries/views are linked to FE's.
    I would not put queries in the back end as a general rule.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 13
    Last Post: 12-28-2016, 11:39 AM
  2. Replies: 2
    Last Post: 12-17-2013, 04:16 PM
  3. Replies: 3
    Last Post: 09-07-2012, 12:50 PM
  4. Replies: 7
    Last Post: 11-16-2011, 01:22 PM
  5. Prevent Users from Deleting Records
    By DocOrganizer in forum Access
    Replies: 15
    Last Post: 11-30-2010, 02:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums