Geoff
10-30-2014, 03:16 PM
I have a VBa program which uses data about various cases. Quite a lot of data is stored for each case. Records are invariably located by case number. So I have two database files. One contains all the case details, and the other is a simple index file which stores the case numbers and the record location of each case in the main database file. To fetch a record, I look it up in the index by searching the case numbers, read the record number and then read in all the data from that record number in the main file (the main file is about 200x the size of the index file). The process is reversed for saving a new case - it is added at a new record at the end of the main database, and that record number is saved to the index file with the case number.
At the moment, each user has his own record of his cases on his computer.
I now want to share those records on a common drive, and have also written a little proglette so that the staff can enter the case details (to assist my colleagues who are keyboard-challenged).
Presumably I will need to lock the files when they are opened for reading or writing, and close them again. Although this operation is over in the blink of an eye, it is inevitable that sooner or later (and sod's law says sooner rather than later) someone will try to read from the files at exactly the moment that someone else is writing to them.
What will happen? Will the code that encounters the locked file try again? Or collapse? Or report the lock and ask what to do? Should I be handling this in code? If so, how? is it as simple as "If #x Locked Then do it again"?
Please tell me it is :-)
TIA for any help.
Geoff
Geoff
At the moment, each user has his own record of his cases on his computer.
I now want to share those records on a common drive, and have also written a little proglette so that the staff can enter the case details (to assist my colleagues who are keyboard-challenged).
Presumably I will need to lock the files when they are opened for reading or writing, and close them again. Although this operation is over in the blink of an eye, it is inevitable that sooner or later (and sod's law says sooner rather than later) someone will try to read from the files at exactly the moment that someone else is writing to them.
What will happen? Will the code that encounters the locked file try again? Or collapse? Or report the lock and ask what to do? Should I be handling this in code? If so, how? is it as simple as "If #x Locked Then do it again"?
Please tell me it is :-)
TIA for any help.
Geoff
Geoff