Record Selector equivalent in code?

andrewf10

Registered User.
Local time
Today, 00:08
Joined
Mar 2, 2003
Messages
114
Hi, I know I'll probably have to wait until Access 2015 is released but has anyone ever come across a way of hiding record selectors on a form and handling it through code instead?

I'd like to test if a record is locked when it's made current and if so, produce a message box. I thought it would've gone like this but obviously not! Thanks

*************************************************
Private Sub Form_Current()
On Error GoTo Err_Form_Current

If Me.CurrentRecord.Locked = True Then
Msgbox "Record is currently locked."
End If

Exit_Form_Current:
Exit Sub

Err_Form_Current:
MsgBox Err.Number, Err.Description
Resume Exit_Form_Current

End Sub
 
The only way I know to lock individual records is to have a CheckBox field in the table. If you want to lock the record then check that field. When the records are displayed in a form you can use code (On Current event) to check the status of the checkbox and then lock the form for that record and make a label visible that says the record is locked. Or you can pop up a message box if you don't want to use the label.

If Me.chkLocked = True Then
Me.AllowEdits = False
MsgBox "This Record Is Locked"
Else
Me.AllowEdits = True
End If


hth,
Jack
 
Thanks Jack, I'm going to start working on this method now.
 
When a record is locked, the record selector changes from a right-pointing triangle to a circle with a slash through it. So the locked property probably does return the correct status but the record is not locked when you think it is.

What is wrong with the way Jet manages record locks? Rolling your own, so to speak, is an awful lot of work to what end?
 
Among other things I'm trying to give users visibility of who is locking the record and a textbox with the 'lockers' username in it would do the trick. I'll admit it is proving really tough, especially trying to work it around the brilliant 'Mousetrap' code.

Also, for some reason my users insist on trying to save a record that the record-locking correctly wouldnt let them update, which is then bringing them into Debug mode. Having gotten them (eventually) into the habit of saving regularly, getting them not to press the save button is proving impossible.
 

Users who are viewing this thread

Back
Top Bottom