If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Code to make table exclusive
Hello, I have in my split database a form that relies on one table (ApptDis).
When a user on the network has that form open, I'd like to inform/block any other user from opening the form by denying the table read property. I've started working on the code to go in the OnOpen event of the form, and so far I have: Dim rst As Recordset Dim Answer As Integer Answer = MsgBox("Form in use by another user...Please Wait", vbOKOnly) Set rst = CurrentDb.OpenRecordset("ApptDis", dbOpenTable, dbDenyRead) If Err.Number 0 Then MsgBox ("Err Number = 0") If Answer = vbOK Then Exit Function End If End If rst.Close But it does not work, I get an error message saying that the table has a process running and cannot be locked. I don't know what that process might be. Am I on the right path? or am I going in the wrong direction entirely? Any help would be greatly appreciated. Paul |
#2
|
|||
|
|||
Code to make table exclusive
Paul,
I think, if I wanted to prevent more than one person having access to a form at a time (I cannot really think of a reason to do this). I would add a field (Yes/No) to my db_Parameters table. Then in the forms Open event, I would check to see whether this value was true. If so, I would cancel the load. If false, I would set it to True, then continue opening the form. Then, in the forms close event, I would set it to false. HTH Dale -- Don''t forget to rate the post if it was helpful! email address is invalid Please reply to newsgroup only. "Paul3rd" wrote: Hello, I have in my split database a form that relies on one table (ApptDis). When a user on the network has that form open, I'd like to inform/block any other user from opening the form by denying the table read property. I've started working on the code to go in the OnOpen event of the form, and so far I have: Dim rst As Recordset Dim Answer As Integer Answer = MsgBox("Form in use by another user...Please Wait", vbOKOnly) Set rst = CurrentDb.OpenRecordset("ApptDis", dbOpenTable, dbDenyRead) If Err.Number 0 Then MsgBox ("Err Number = 0") If Answer = vbOK Then Exit Function End If End If rst.Close But it does not work, I get an error message saying that the table has a process running and cannot be locked. I don't know what that process might be. Am I on the right path? or am I going in the wrong direction entirely? Any help would be greatly appreciated. Paul |
#3
|
|||
|
|||
Code to make table exclusive
Thanks Dale,
My form has an imbedded worksheet as an OLE object. The form opens onto the current date and I wanted to eliminate the possibility of two (or more) people trying to edit the worksheet simultaneously. I'll work on it some more, Thanks again for the advice. Paul "Dale Fye" wrote: Paul, I think, if I wanted to prevent more than one person having access to a form at a time (I cannot really think of a reason to do this). I would add a field (Yes/No) to my db_Parameters table. Then in the forms Open event, I would check to see whether this value was true. If so, I would cancel the load. If false, I would set it to True, then continue opening the form. Then, in the forms close event, I would set it to false. HTH Dale -- Don''t forget to rate the post if it was helpful! email address is invalid Please reply to newsgroup only. "Paul3rd" wrote: Hello, I have in my split database a form that relies on one table (ApptDis). When a user on the network has that form open, I'd like to inform/block any other user from opening the form by denying the table read property. I've started working on the code to go in the OnOpen event of the form, and so far I have: Dim rst As Recordset Dim Answer As Integer Answer = MsgBox("Form in use by another user...Please Wait", vbOKOnly) Set rst = CurrentDb.OpenRecordset("ApptDis", dbOpenTable, dbDenyRead) If Err.Number 0 Then MsgBox ("Err Number = 0") If Answer = vbOK Then Exit Function End If End If rst.Close But it does not work, I get an error message saying that the table has a process running and cannot be locked. I don't know what that process might be. Am I on the right path? or am I going in the wrong direction entirely? Any help would be greatly appreciated. Paul |
Thread Tools | |
Display Modes | |
|
|