A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Code to make table exclusive



 
 
Thread Tools Display Modes
  #1  
Old March 1st, 2008, 10:11 PM posted to microsoft.public.access.gettingstarted
Paul3rd
external usenet poster
 
Posts: 71
Default 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  
Old March 2nd, 2008, 01:36 AM posted to microsoft.public.access.gettingstarted
Dale Fye
external usenet poster
 
Posts: 2,651
Default 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  
Old March 2nd, 2008, 03:55 PM posted to microsoft.public.access.gettingstarted
Paul3rd
external usenet poster
 
Posts: 71
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:02 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.