Record Locking

W

Wayne & Kerri Anne

Hi All

Is there a way of locking just one record in a access 97 database.

I would like to do this because i have written a vb6 program and if the user
deletes all records then they cause an error because there is no records in
the database havn't found a fix for that yet thats why I am asking.


Kind Reagrds
Wayne
 
A

Allen Browne

You cannot place a permanent lock on a single record.

Your code does need to check whether there are records to deal with. The
solution would be to change the code so it copes with no records, rather
than to force the database to always have records.

For example, if you OpenRecordset, it is very easy to check the RecordCount
property. The property will be 0 of there are no records, 1 if a record was
found, or more than 1 if many records were successfuly loaded at once
(typically on a Table type recordset.)

If you use ADO recordsets, it could also be -1 for the types where it does
not know if there are records, but let's ignore that and give a DAO example:
Set rs = db.OpenRecordset("Table1", dbOpenDynaset)
If rs.RecordCount > 0 Then
'Put your code in here.
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top