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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check For Record Locking

Status
Not open for further replies.

anon47

Programmer
Nov 28, 2006
80
US
Below is the code I posted in the access form and ACMan1 was really helpful but I still can't get it to work.

I am tring to have the code upon on click of the payment button give an error message if the record is being edited. I am stumped!

Private Sub MakePayments_Click()
If Not Forms!sProjects.Recordset.Locked = False Then
stDocName = "Payments"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Record Being Edited (Try Later)"
End If
End Sub
 
Sorry Error Message if the record is locked.
 
so does your If statement work?
if it doesnt work then you are getting an error if the record is locked? therefore you cant write to it?
if you are producing a run time error when the record is locked then (i do prefer defensive programming but) trap the error and act accordingly
 
That looks more like Access VBA than VBScript. There is no ! operator for Collections access in VBScript. Wrong forum.

Also, isn't:

[tt]If Not Forms!sProjects.Recordset.Locked = False Then[/tt]

... the same as:

[tt]If Forms!sProjects.Recordset.Locked = True Then[/tt]

... ?

If so, is your problem that you have reversed the sense of the test from what you really want?

And what is this [tt]Locked[/tt] property? I don't see such a property listed for either an ADO or DAO [tt]Recordset[/tt] object.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top