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
Printable View
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
How many machines will it be installed on?
It is accessed via a shared network drive and will be used by about 6 people.
Are you using a database?
Yes, Access... using ancient code too.
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.
Great idea.
Thanks.
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?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.Quote:
Originally Posted by jcar123
If that happens, you would need to open the database with Access itself, and manually reset the flag.
Please help with error trapping. I haven't programmed for many years..........quite rusty.
This type of thing needs to go everywhere there is codeYes, 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.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
Thanks. Only issue left is the timing out issue.