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 biv343 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 also posted it in VB Scripts and was told that was the wrong form. My final attempt is here.

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
 
Making a dozen assumptions, try something like:

If Me.Dirty then
' The record is being edited
Else
' The record is NOT being edited
End If




Learn from the mistakes of others. You won't live long enough to make all of them yourself.
 
anon47 said:
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

In your code, if Forms!sProjects.Recordset.Locked = True then your IF..THEN evaluates to true and the statements within the THEN clause execute, the opposite of what you want. Use the following instead:
Code:
If Not Forms!sProjects.Recordset.Locked Then


Regards,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top