Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display Next Record in query if current record is locked

Status
Not open for further replies.

primagic

IS-IT--Management
Jul 24, 2008
476
0
0
GB
ANyone know how I can check to see if a record is looked and if so, display the next free record in the query?

My code is:

Code:
Dim db As Database
Dim rst As DAO.Recorset
Dim strCriteria As String

Set db = CurrentDb
Set rst = db.OpenRecordsest("NextTaskList")
strCriteria = "TempAdviserLock = 'Free'"
rst.FindFirst strCriteria
If rst.NoMatch Then
MsgBox "There are no matching records"
Else
MsgBox "Record found"
End If
rs
rst.Close
 
If you open your recordset in Pessimistic locking mode, issuing rst.Edit when the record is already locked will generate an error.

If the mode is 'Optimistic', you need to do both .Edit and .Update to check if the record is locked.

Test the error code and try a rst.FindNext


[pipe]
Daniel Vlas
Systems Consultant

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top