|
-
Sep 24th, 2007, 08:35 AM
#1
Thread Starter
Lively Member
[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
-
Sep 24th, 2007, 08:36 AM
#2
Re: Restricting use of VB program to 1 user
How many machines will it be installed on?
-
Sep 24th, 2007, 09:03 AM
#3
Thread Starter
Lively Member
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.
-
Sep 24th, 2007, 09:20 AM
#4
Re: Restricting use of VB program to 1 user
Are you using a database?
-
Sep 25th, 2007, 03:17 AM
#5
Thread Starter
Lively Member
Re: Restricting use of VB program to 1 user
Yes, Access... using ancient code too.
-
Sep 25th, 2007, 05:50 AM
#6
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.
-
Sep 25th, 2007, 06:37 AM
#7
Thread Starter
Lively Member
Re: Restricting use of VB program to 1 user
-
Sep 25th, 2007, 06:41 AM
#8
Thread Starter
Lively Member
Re: Restricting use of VB program to 1 user
What about timing out the program?
-
Sep 25th, 2007, 07:03 AM
#9
Re: Restricting use of VB program to 1 user
 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?
-
Sep 25th, 2007, 07:07 AM
#10
Thread Starter
Lively Member
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.
-
Sep 25th, 2007, 07:09 AM
#11
Re: Restricting use of VB program to 1 user
 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.
-
Sep 25th, 2007, 07:19 AM
#12
Thread Starter
Lively Member
Re: Restricting use of VB program to 1 user
Please help with error trapping. I haven't programmed for many years..........quite rusty.
-
Sep 25th, 2007, 07:38 AM
#13
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.
-
Sep 25th, 2007, 08:52 AM
#14
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|