Results 1 to 14 of 14

Thread: [RESOLVED] Restricting use of VB program to 1 user

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    98

    Resolved [RESOLVED] Restricting use of VB program to 1 user

    Please does anyone know how to restrict user access of the VB program to 1 user at a time?
    Also, I would like to create a timer so if the program is idle for more than 1 hour, it closes.
    Thanks

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Restricting use of VB program to 1 user

    How many machines will it be installed on?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    98

    Re: Restricting use of VB program to 1 user

    It is accessed via a shared network drive and will be used by about 6 people.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Restricting use of VB program to 1 user

    Are you using a database?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    98

    Re: Restricting use of VB program to 1 user

    Yes, Access... using ancient code too.

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Restricting use of VB program to 1 user

    Well, the easiest way would be to great a flag field in your database.

    As soon as someone executes your program, run a query against that field. If it is empty, then put a character in it. A 0 or a 1 or a T or something like that.

    If it is not empty, then you know someone else is using the program, so be nice and pop up a message box indicating why the program can not be used at this time. When the user clicks OK, end the program.

    When the first user exists from the program, write a delete query to remove the character from the flag field so that the next person to come along can get in.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    98

    Re: Restricting use of VB program to 1 user

    Great idea.
    Thanks.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    98

    Re: Restricting use of VB program to 1 user

    What about timing out the program?

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Restricting use of VB program to 1 user

    Quote Originally Posted by jcar123
    What about timing out the program?
    Meaning if it is activated by someone, but no activity is logged for x amount of time, end it?

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    98

    Re: Restricting use of VB program to 1 user

    Yes.
    Please can you also advise me on how to set the flag mentioned in your previous reply back to 0 (no users using the program) in the case of the program "crashing" on error or closing the window using the X. Otherwise the person will not be able to get back into it.

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Restricting use of VB program to 1 user

    Quote Originally Posted by jcar123
    Yes.
    Please can you also advise me on how to set the flag mentioned in your previous reply back to 0 (no users using the program) in the case of the program "crashing" on error or closing the window using the X. Otherwise the person will not be able to get back into it.
    If properly error trapped, you program will not crash unless Windows itself crashes and something like that you can not avoid.

    If that happens, you would need to open the database with Access itself, and manually reset the flag.

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    98

    Re: Restricting use of VB program to 1 user

    Please help with error trapping. I haven't programmed for many years..........quite rusty.

  13. #13
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Restricting use of VB program to 1 user

    This type of thing needs to go everywhere there is code
    Code:
    Private Sub Command1_Click()
    On Error GoTo ErrTrap
    'code for button click is here
    Exit Sub
    ErrTrap:
    Msgbox "A error has occurred.  It is " & err.Number & " " & err.Description
    End Sub
    Yes, it is a pain to error trap all of your code. However, it is only a pain for you, and will not compare to the pain and frustration your users will suffer if they encounter an untrapped runtime error that ends your application and pops them right back to the desktop.

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    98

    Re: Restricting use of VB program to 1 user

    Thanks. Only issue left is the timing out issue.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width