Welcome to Windows Help!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

record locks

 
   Windows Help (Home) -> Microsoft Access RSS
Next:  Can't see replies to questions from this source  
Author Message
OD

External


Since: Nov 28, 2008
Posts: 6



(Msg. 1) Posted: Fri Nov 28, 2008 6:47 am
Post subject: record locks
Archived from groups: microsoft>public>access (more info?)

I need to check to see if a user has placed a editrecord lock on a record. Is
thier a good way to test for a lock. If I know that thier is a lock set then
I can do something. Right now I have the form set to no locks.


Thanks OD

 >> Stay informed about: record locks 
Back to top
Login to vote
Kay Davies

External


Since: Nov 26, 2008
Posts: 1



(Msg. 2) Posted: Fri Nov 28, 2008 9:30 am
Post subject: RE: record locks
Archived from groups: per prev. post (more info?)

Hi OD
if you go into the design view of the form and bring up the properties of
the record that you are interested in (by right clicking whilst it is
highlighted) then you should be able to see whether it is set to read only.

hope this helps

 >> Stay informed about: record locks 
Back to top
Login to vote
Ken Sheridan

External


Since: Nov 28, 2008
Posts: 17



(Msg. 3) Posted: Fri Nov 28, 2008 10:01 am
Post subject: RE: record locks
Archived from groups: per prev. post (more info?)

Optimistic locking (no locks) doesn't make a lot of sense these days. It was
popular before Access 2002 when Access could only use page locking, not
record locking as it avoided other records on the page being locked as well
as the record being edited. If pessimistic locking (edited record) is used,
provide the record selectors are shown on your form, if you try to edit a
record which is currently locked by another user then the record selector
will turn from the pencil symbol to a 'no entry' sign, and you won't be able
to edit it.

Ken Sheridan
Stafford, England

"OD" wrote:

> I need to check to see if a user has placed a editrecord lock on a record. Is
> thier a good way to test for a lock. If I know that thier is a lock set then
> I can do something. Right now I have the form set to no locks.
>
>
> Thanks OD
 >> Stay informed about: record locks 
Back to top
Login to vote
OD

External


Since: Nov 28, 2008
Posts: 6



(Msg. 4) Posted: Fri Nov 28, 2008 10:17 am
Post subject: RE: record locks
Archived from groups: per prev. post (more info?)

"Ken Sheridan" wrote:

> Optimistic locking (no locks) doesn't make a lot of sense these days. It was
> popular before Access 2002 when Access could only use page locking, not
> record locking as it avoided other records on the page being locked as well
> as the record being edited. If pessimistic locking (edited record) is used,
> provide the record selectors are shown on your form, if you try to edit a
> record which is currently locked by another user then the record selector
> will turn from the pencil symbol to a 'no entry' sign, and you won't be able
> to edit it.
>
> Ken Sheridan
> Stafford, England
>
> "OD" wrote:
>
> > I need to check to see if a user has placed a editrecord lock on a record. Is
> > thier a good way to test for a lock. If I know that thier is a lock set then
> > I can do something. Right now I have the form set to no locks.
> >
> >
> > Thanks OD
>
I'm not using the record selector in my form. So with code I need to see if
this record is locked by onother user. I looked to something like islocked().
then I could use something like "if islocked() = true then do something endif"

Thanks OD
 >> Stay informed about: record locks 
Back to top
Login to vote
Ken Sheridan

External


Since: Nov 28, 2008
Posts: 17



(Msg. 5) Posted: Fri Nov 28, 2008 11:09 am
Post subject: RE: record locks
Archived from groups: per prev. post (more info?)

No trappable error is raised if you try to edit the form. Access will beep
at the user, but that's all. You could perhaps try changing the value of a
bound control to itself in code and see if a runtime error is raised if the
record is locked by another user. If so you could then trap this error.

Ken Sheridan
Stafford, England

"OD" wrote:

>
>
> "Ken Sheridan" wrote:
>
> > Optimistic locking (no locks) doesn't make a lot of sense these days. It was
> > popular before Access 2002 when Access could only use page locking, not
> > record locking as it avoided other records on the page being locked as well
> > as the record being edited. If pessimistic locking (edited record) is used,
> > provide the record selectors are shown on your form, if you try to edit a
> > record which is currently locked by another user then the record selector
> > will turn from the pencil symbol to a 'no entry' sign, and you won't be able
> > to edit it.
> >
> > Ken Sheridan
> > Stafford, England
> >
> > "OD" wrote:
> >
> > > I need to check to see if a user has placed a editrecord lock on a record. Is
> > > thier a good way to test for a lock. If I know that thier is a lock set then
> > > I can do something. Right now I have the form set to no locks.
> > >
> > >
> > > Thanks OD
> >
> I'm not using the record selector in my form. So with code I need to see if
> this record is locked by onother user. I looked to something like islocked().
> then I could use something like "if islocked() = true then do something endif"
>
> Thanks OD
 >> Stay informed about: record locks 
Back to top
Login to vote
OD

External


Since: Nov 28, 2008
Posts: 6



(Msg. 6) Posted: Fri Nov 28, 2008 2:24 pm
Post subject: RE: record locks
Archived from groups: per prev. post (more info?)

"Ken Sheridan" wrote:

> No trappable error is raised if you try to edit the form. Access will beep
> at the user, but that's all. You could perhaps try changing the value of a
> bound control to itself in code and see if a runtime error is raised if the
> record is locked by another user. If so you could then trap this error.
>
> Ken Sheridan
> Stafford, England
>
> "OD" wrote:
>
> >
> >
> > "Ken Sheridan" wrote:
> >
> > > Optimistic locking (no locks) doesn't make a lot of sense these days. It was
> > > popular before Access 2002 when Access could only use page locking, not
> > > record locking as it avoided other records on the page being locked as well
> > > as the record being edited. If pessimistic locking (edited record) is used,
> > > provide the record selectors are shown on your form, if you try to edit a
> > > record which is currently locked by another user then the record selector
> > > will turn from the pencil symbol to a 'no entry' sign, and you won't be able
> > > to edit it.
> > >
> > > Ken Sheridan
> > > Stafford, England
> > >
> > > "OD" wrote:
> > >
> > > > I need to check to see if a user has placed a editrecord lock on a record. Is
> > > > thier a good way to test for a lock. If I know that thier is a lock set then
> > > > I can do something. Right now I have the form set to no locks.
> > > >
> > > >
> > > > Thanks OD
> > >
> > I'm not using the record selector in my form. So with code I need to see if
> > this record is locked by onother user. I looked to something like islocked().
> > then I could use something like "if islocked() = true then do something endif"
> >
> > Thanks OD
>
Is thier away to check to see if a recoord is lockeked at the record level
instead of at the form level. If the record selector is getting the info is
thier away to get it from the record selector.

By the way I'm new to using Access, I realy have not done too much
programing sence my Paradox for dos days, I under stood how Paradox Locks
worked. So I'm trying to get a handle on how Access does it.

thanks
 >> Stay informed about: record locks 
Back to top
Login to vote
Ken Sheridan

External


Since: Nov 28, 2008
Posts: 17



(Msg. 7) Posted: Fri Nov 28, 2008 3:50 pm
Post subject: RE: record locks
Archived from groups: per prev. post (more info?)

I know of no way of addressing the record selector.

You could try updating any non_Null column (i.e. a Required column) to
itself in a function like this:

Public Function IsLocked(strtable As String, _
strColumn As String, _
strKey As String, _
lngID As Long) As Boolean

Const conRECORDLOCKED = -2147467259
Dim cmd As ADODB.Command
Dim strSQL As String

IsLocked = False

Set cmd = New ADODB.Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandType = adCmdText

' attempt to update row in table
strSQL = "UPDATE(" & strtable & ")" & _
" SET " & strColumn & " = " & strColumn & _
" WHERE " & strKey & " = " & lngID
cmd.CommandText = strSQL
On Error Resume Next
cmd.Execute
Select Case Err.Number
Case 0
' no error
Case conRECORDLOCKED
' record is locked
IsLocked = True
Case Else
' unknown error
MsgBox Err.Description, vbExclamation, "Error"
End Select

End Function

This seems to work if called from code in a standard module, e.g.

Debug.Print IsLocked("Contacts","Lastname","ContactID",2)

but not if called in a form's class module and the value of the current
record's primary key is passed to the function, e.g.

Dim lngID As Long

lngID = Me.ContactID

If IsLocked("Contacts","Lastname","ContactID", lngID) Then
MsgBox "Record is locked."
End If

in which case the IsLocked function returns True for every record. Even if
the values are passed to a procedure in a standard module and then to the
function the same happens. I expect there's a rational explanation, but It
makes no sense to me, I'm afraid.

Ken Sheridan
Stafford, England

"OD" wrote:

>
>
> "Ken Sheridan" wrote:
>
> > No trappable error is raised if you try to edit the form. Access will beep
> > at the user, but that's all. You could perhaps try changing the value of a
> > bound control to itself in code and see if a runtime error is raised if the
> > record is locked by another user. If so you could then trap this error.
> >
> > Ken Sheridan
> > Stafford, England
> >
> > "OD" wrote:
> >
> > >
> > >
> > > "Ken Sheridan" wrote:
> > >
> > > > Optimistic locking (no locks) doesn't make a lot of sense these days. It was
> > > > popular before Access 2002 when Access could only use page locking, not
> > > > record locking as it avoided other records on the page being locked as well
> > > > as the record being edited. If pessimistic locking (edited record) is used,
> > > > provide the record selectors are shown on your form, if you try to edit a
> > > > record which is currently locked by another user then the record selector
> > > > will turn from the pencil symbol to a 'no entry' sign, and you won't be able
> > > > to edit it.
> > > >
> > > > Ken Sheridan
> > > > Stafford, England
> > > >
> > > > "OD" wrote:
> > > >
> > > > > I need to check to see if a user has placed a editrecord lock on a record. Is
> > > > > thier a good way to test for a lock. If I know that thier is a lock set then
> > > > > I can do something. Right now I have the form set to no locks.
> > > > >
> > > > >
> > > > > Thanks OD
> > > >
> > > I'm not using the record selector in my form. So with code I need to see if
> > > this record is locked by onother user. I looked to something like islocked().
> > > then I could use something like "if islocked() = true then do something endif"
> > >
> > > Thanks OD
> >
> Is thier away to check to see if a recoord is lockeked at the record level
> instead of at the form level. If the record selector is getting the info is
> thier away to get it from the record selector.
>
> By the way I'm new to using Access, I realy have not done too much
> programing sence my Paradox for dos days, I under stood how Paradox Locks
> worked. So I'm trying to get a handle on how Access does it.
>
> thanks
 >> Stay informed about: record locks 
Back to top
Login to vote
OD

External


Since: Nov 28, 2008
Posts: 6



(Msg. 8) Posted: Sun Nov 30, 2008 6:31 am
Post subject: RE: record locks
Archived from groups: per prev. post (more info?)

"Ken Sheridan" wrote:

> I know of no way of addressing the record selector.
>
> You could try updating any non_Null column (i.e. a Required column) to
> itself in a function like this:
>
> Public Function IsLocked(strtable As String, _
> strColumn As String, _
> strKey As String, _
> lngID As Long) As Boolean
>
> Const conRECORDLOCKED = -2147467259
> Dim cmd As ADODB.Command
> Dim strSQL As String
>
> IsLocked = False
>
> Set cmd = New ADODB.Command
> cmd.ActiveConnection = CurrentProject.Connection
> cmd.CommandType = adCmdText
>
> ' attempt to update row in table
> strSQL = "UPDATE(" & strtable & ")" & _
> " SET " & strColumn & " = " & strColumn & _
> " WHERE " & strKey & " = " & lngID
> cmd.CommandText = strSQL
> On Error Resume Next
> cmd.Execute
> Select Case Err.Number
> Case 0
> ' no error
> Case conRECORDLOCKED
> ' record is locked
> IsLocked = True
> Case Else
> ' unknown error
> MsgBox Err.Description, vbExclamation, "Error"
> End Select
>
> End Function
>
> This seems to work if called from code in a standard module, e.g.
>
> Debug.Print IsLocked("Contacts","Lastname","ContactID",2)
>
> but not if called in a form's class module and the value of the current
> record's primary key is passed to the function, e.g.
>
> Dim lngID As Long
>
> lngID = Me.ContactID
>
> If IsLocked("Contacts","Lastname","ContactID", lngID) Then
> MsgBox "Record is locked."
> End If
>
> in which case the IsLocked function returns True for every record. Even if
> the values are passed to a procedure in a standard module and then to the
> function the same happens. I expect there's a rational explanation, but It
> makes no sense to me, I'm afraid.
>
> Ken Sheridan
> Stafford, England
>
> "OD" wrote:
>
> >
> >
> > "Ken Sheridan" wrote:
> >
> > > No trappable error is raised if you try to edit the form. Access will beep
> > > at the user, but that's all. You could perhaps try changing the value of a
> > > bound control to itself in code and see if a runtime error is raised if the
> > > record is locked by another user. If so you could then trap this error.
> > >
> > > Ken Sheridan
> > > Stafford, England
> > >
> > > "OD" wrote:
> > >
> > > >
> > > >
> > > > "Ken Sheridan" wrote:
> > > >
> > > > > Optimistic locking (no locks) doesn't make a lot of sense these days. It was
> > > > > popular before Access 2002 when Access could only use page locking, not
> > > > > record locking as it avoided other records on the page being locked as well
> > > > > as the record being edited. If pessimistic locking (edited record) is used,
> > > > > provide the record selectors are shown on your form, if you try to edit a
> > > > > record which is currently locked by another user then the record selector
> > > > > will turn from the pencil symbol to a 'no entry' sign, and you won't be able
> > > > > to edit it.
> > > > >
> > > > > Ken Sheridan
> > > > > Stafford, England
> > > > >
> > > > > "OD" wrote:
> > > > >
> > > > > > I need to check to see if a user has placed a editrecord lock on a record. Is
> > > > > > thier a good way to test for a lock. If I know that thier is a lock set then
> > > > > > I can do something. Right now I have the form set to no locks.
> > > > > >
> > > > > >
> > > > > > Thanks OD
> > > > >
> > > > I'm not using the record selector in my form. So with code I need to see if
> > > > this record is locked by onother user. I looked to something like islocked().
> > > > then I could use something like "if islocked() = true then do something endif"
> > > >
> > > > Thanks OD
> > >
> > Is thier away to check to see if a recoord is lockeked at the record level
> > instead of at the form level. If the record selector is getting the info is
> > thier away to get it from the record selector.
> >
> > By the way I'm new to using Access, I realy have not done too much
> > programing sence my Paradox for dos days, I under stood how Paradox Locks
> > worked. So I'm trying to get a handle on how Access does it.
> >
> > thanks
>
Thanks Ken,

I had to change some of the things that I do in the forms, this project is
just for 5 users, and I can live with the problem. One of the problems that I
had was, I don't like the way Access stores the data in a table. I was having
to use ucase([field name]) to make sure the the data was stored in upper
case. I don;t like just using the format > command, because it may be
displayed in uppercase its not stored that way. Its not a big problem, it
just bugs me.

Thanks agian for the help.

OD
 >> Stay informed about: record locks 
Back to top
Login to vote
Ken Sheridan

External


Since: Nov 28, 2008
Posts: 17



(Msg. 9) Posted: Sun Nov 30, 2008 7:07 am
Post subject: RE: record locks
Archived from groups: per prev. post (more info?)

You can force input in a control in a form to upper case by putting the
following procedure in a standard module:

Public Sub ConvertToCaps(KeyAscii As Integer)
' Converts text typed into control to upper case

On Error GoTo Err_Handler

Dim strCharacter As String

' Convert ANSI value to character string.
strCharacter = Chr(KeyAscii)
' Convert character to upper case, then to ANSI value.
KeyAscii = Asc(UCase(strCharacter))

Exit_Here:
Exit Sub

Err_Handler:
MsgBox Err.Description & " (" & Err.Number & ")", vbExclamation, "Error"
Resume Exit_Here

End Sub

Then in the KeyPress event procedure of any control whose text you want
forced to upper case put:

ConvertToCaps KeyAscii

Note that you must call the procedure in the event procedure. You cannot
make it a function and call it directly from the control's properties sheet
as you normally would when using a function as an event property.

Ken Sheridan
Stafford, England

"OD" wrote:

> Thanks Ken,
>
> I had to change some of the things that I do in the forms, this project is
> just for 5 users, and I can live with the problem. One of the problems that I
> had was, I don't like the way Access stores the data in a table. I was having
> to use ucase([field name]) to make sure the the data was stored in upper
> case. I don;t like just using the format > command, because it may be
> displayed in uppercase its not stored that way. Its not a big problem, it
> just bugs me.
>
> Thanks agian for the help.
>
> OD
 >> Stay informed about: record locks 
Back to top
Login to vote
OD

External


Since: Nov 28, 2008
Posts: 6



(Msg. 10) Posted: Sun Nov 30, 2008 7:23 am
Post subject: RE: record locks
Archived from groups: per prev. post (more info?)

Thanks Ken
That was a fast response, I think that will help with one of my problems.

Thanks
OD

"Ken Sheridan" wrote:

> You can force input in a control in a form to upper case by putting the
> following procedure in a standard module:
>
> Public Sub ConvertToCaps(KeyAscii As Integer)
> ' Converts text typed into control to upper case
>
> On Error GoTo Err_Handler
>
> Dim strCharacter As String
>
> ' Convert ANSI value to character string.
> strCharacter = Chr(KeyAscii)
> ' Convert character to upper case, then to ANSI value.
> KeyAscii = Asc(UCase(strCharacter))
>
> Exit_Here:
> Exit Sub
>
> Err_Handler:
> MsgBox Err.Description & " (" & Err.Number & ")", vbExclamation, "Error"
> Resume Exit_Here
>
> End Sub
>
> Then in the KeyPress event procedure of any control whose text you want
> forced to upper case put:
>
> ConvertToCaps KeyAscii
>
> Note that you must call the procedure in the event procedure. You cannot
> make it a function and call it directly from the control's properties sheet
> as you normally would when using a function as an event property.
>
> Ken Sheridan
> Stafford, England
>
> "OD" wrote:
>
> > Thanks Ken,
> >
> > I had to change some of the things that I do in the forms, this project is
> > just for 5 users, and I can live with the problem. One of the problems that I
> > had was, I don't like the way Access stores the data in a table. I was having
> > to use ucase([field name]) to make sure the the data was stored in upper
> > case. I don;t like just using the format > command, because it may be
> > displayed in uppercase its not stored that way. Its not a big problem, it
> > just bugs me.
> >
> > Thanks agian for the help.
> >
> > OD
>
 >> Stay informed about: record locks 
Back to top
Login to vote
OD

External


Since: Nov 28, 2008
Posts: 6



(Msg. 11) Posted: Sun Nov 30, 2008 8:15 am
Post subject: RE: record locks
Archived from groups: per prev. post (more info?)

Ken Thanks,

I just tried the convertToCaps, I works great, now I will fix my forms.

Thanks a lot it really helped.

OD

"OD" wrote:

>
> Thanks Ken
> That was a fast response, I think that will help with one of my problems.
>
> Thanks
> OD
>
> "Ken Sheridan" wrote:
>
> > You can force input in a control in a form to upper case by putting the
> > following procedure in a standard module:
> >
> > Public Sub ConvertToCaps(KeyAscii As Integer)
> > ' Converts text typed into control to upper case
> >
> > On Error GoTo Err_Handler
> >
> > Dim strCharacter As String
> >
> > ' Convert ANSI value to character string.
> > strCharacter = Chr(KeyAscii)
> > ' Convert character to upper case, then to ANSI value.
> > KeyAscii = Asc(UCase(strCharacter))
> >
> > Exit_Here:
> > Exit Sub
> >
> > Err_Handler:
> > MsgBox Err.Description & " (" & Err.Number & ")", vbExclamation, "Error"
> > Resume Exit_Here
> >
> > End Sub
> >
> > Then in the KeyPress event procedure of any control whose text you want
> > forced to upper case put:
> >
> > ConvertToCaps KeyAscii
> >
> > Note that you must call the procedure in the event procedure. You cannot
> > make it a function and call it directly from the control's properties sheet
> > as you normally would when using a function as an event property.
> >
> > Ken Sheridan
> > Stafford, England
> >
> > "OD" wrote:
> >
> > > Thanks Ken,
> > >
> > > I had to change some of the things that I do in the forms, this project is
> > > just for 5 users, and I can live with the problem. One of the problems that I
> > > had was, I don't like the way Access stores the data in a table. I was having
> > > to use ucase([field name]) to make sure the the data was stored in upper
> > > case. I don;t like just using the format > command, because it may be
> > > displayed in uppercase its not stored that way. Its not a big problem, it
> > > just bugs me.
> > >
> > > Thanks agian for the help.
> > >
> > > OD
> >
 >> Stay informed about: record locks 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Change of Record - What event would describe moving from one record to another in a form? I've incorporated a tab control into my form and I'd like to deisgn it so that when a user is on any tab other than the 1st one, if the user moves to another record (e.g., using th...

Creating Multiple Record - I was curious to find out how to create multiple records for an employee. I want to be able to select an employee and schedule vacations and multiple days off from work. Here is what my tables look like: tblEmployee Employee ID (PK) NAME ..

how to create new record automatically - Hi, I have a form a form to show the customer information and I button to create new order for him. The Order form has the following fields: OrderID>>>autonumber cutomerID employeeID …. Also, there is a subform that is bounded on the Order De...

Circumvent "At most one record can be returned by this sub.. - Hi, I have a nested query, in which the subquery can return more than one record, but this is not allowed by Access. I've found various posts where people have gotten the error, "At most one record can be returned by this subquery" and really ...

How to return record counter to the zero position - Hi, I will to restart the record counter in my db. I deleted all records from the db. I tryied to make compact an repair it didn't help. I also triyed in the tables designvy to erase primarykey and write it again it didn't help. Do someone knows how to...
   Windows Help (Home) -> Microsoft Access All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]