Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2017
    Posts
    12

    Toggle button/indicator for mutually exclusive event

    First post here, so be gentle



    I have a situation where, in our office, there is a web resource we all use. However, we only have one account which is single-login. So any time someone needs to use this resource, we have to yell out in the office if anyone is logged into the site. Our entire work is central to an Access database, so a simple solution would be to add a clickable box to the switchboard which would turn red in everyone's screen when someone clicks it. They log-in, do their work, then click it when they log-out. That will turn it from red back to normal on everyone else's screens. We would also like to track the user time logged in so we can see how long people spend on the resource.

    Anyone have some good solutions for this?

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You could use a check box, or toggle button. It would set the value of a field in the back end database, directly if the form could be bound to it, or indirectly. The front ends would have to check the value of that field periodically (form's timer event), and set the value of their check box or toggle button to match. It could also set a label background to red.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    I agree with Paul, but rather than using a timer event I would have a 'I want to use the resource' button. When clicked the code checks to see who else is using it. If no one, then set the checkbox and open the resource. If there is, then display a 'not available' message. And rather than a checkbox, store the user name so you've got someone to yell at - with additional start/end times, that will track your usage.

    Problem you have is unchecking when finished with the resource. How to manage that depends on how your db works

    Also, depending on how the website works, you could have it displayed in a webcontrol on a form so opening/closing of the form provides the events you need

  4. #4
    Join Date
    Mar 2017
    Posts
    12
    Quote Originally Posted by Ajax View Post
    I agree with Paul, but rather than using a timer event I would have a 'I want to use the resource' button. When clicked the code checks to see who else is using it. If no one, then set the checkbox and open the resource. If there is, then display a 'not available' message. And rather than a checkbox, store the user name so you've got someone to yell at - with additional start/end times, that will track your usage.

    Problem you have is unchecking when finished with the resource. How to manage that depends on how your db works

    Also, depending on how the website works, you could have it displayed in a webcontrol on a form so opening/closing of the form provides the events you need
    That sounds exactly what I'm after. I haven't developed for Access for years and I'm pretty rusty. I know Access is used as a front end to an SQL database in this particular application. What is the best way to make this toggle happen? I've googled, but if anyone has a quick solution, it would be greatly appreciated.

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    difficult to advise in detail because it really depends how your system works. The below also does not stop users just opening the website manually

    From an access and control perspective, in the first instance I would look at whether you can access and use the website using a web control. If you can then I would create a new popup and modal form with just the web control on and a label saying something like 'close form when finished with web app'. You might include another message warning against leaving it open unnecessarily. If web control doesn't work, include a hyperlink control so users can click on it to open the web app, or use some code in the popup open event to open the web page. Whilst the popup is open, users will not be able to use access so this should encourage them to close it to continue.

    in your backend you will need a table something like

    tblWebUtilisation
    webPK autonumber
    UserName text
    StartDT datetime - default=now()
    EndDT datetime

    On your main form have a button captioned something like 'Use web app'

    in the button click event code something like

    Code:
    dim rst as dao.recordset
    
    set rst=currentdb.openrecordset("SELECT * FROM tblWebUtilisation WHERE EndDT is null")
    if rst.eof then 'no users using web app so OK to open
        currentdb.execute "INSERT INTO tblWebUtilisation (UserName) VALUES('" & environ("USERNAME") & "')"
        docmd.openform "mypopupform"....
    else
        msgbox "User " & rst!username & " has been logged on since " & format(rst!startDT,"hh:nn:")
    end if
    rst.close
    in the close event of the popup form, some code along the lines of

    Code:
    currentdb.execute("UPDATE tblWebUtilisation SET EndDT=Now() WHERE UserName='" & environ("USERNAME") & "' AND EndDT is Null")

    You will not doubt need some management around the table if the popup form is not closed properly to 'unlock' it, otherwise users will not be able to continue.

  6. #6
    Join Date
    Mar 2017
    Posts
    12
    The staff are very capable of checking if anyone is using the resource. There is no need to launch the web service from inside Access. This is merely designed to stop staff members yelling out every time to ask if anyone is using it.

    The simpler the solution, the better.

    It will just be a standard practice of checking for the flag before opening the website and logging in. Then logging out and clicking the flag again.

  7. #7
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    In that case just go for a popup form with just a label saying something like 'close form when finished with web app'

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Use Toggle button to select subform value
    By DerekAwesome in forum Forms
    Replies: 7
    Last Post: 12-02-2012, 07:15 PM
  2. Toggle Button Help
    By dbalilti in forum Access
    Replies: 1
    Last Post: 07-05-2012, 04:23 AM
  3. remove toggle filter button!?
    By Wombat in forum Access
    Replies: 1
    Last Post: 05-16-2012, 01:50 PM
  4. Toggle Button Criteria
    By tylerg11 in forum Forms
    Replies: 2
    Last Post: 03-02-2012, 09:28 AM
  5. Toggle Button Options
    By Matthieu in forum Forms
    Replies: 2
    Last Post: 11-23-2009, 04:05 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