RecordLock - VBA to change all forms in database (1 Viewer)

dgreen

Member
Local time
Today, 13:11
Joined
Sep 30, 2018
Messages
397
A couple of months ago, I thought it would be useful to put record locks on all my forms. Now, I'm resenting the decision.

Instead of spending a couple hours opening each form and changing the record lock setting (over 200 forms), can someone help with code that loops thru every form and changes the property setting?

This is the code to do one form at a time. I need a function that can change all forms.
Code:
Forms("Employees").RecordLocks = 0

1586357003321.png
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:11
Joined
Oct 29, 2018
Messages
21,469
Hi. Maybe you can apply the technique demonstrated here for your purposes. Basically, instead of .RibbonName, mabye try .RecordLocks. Just a thought...

 

dgreen

Member
Local time
Today, 13:11
Joined
Sep 30, 2018
Messages
397
Thanks for the code. I found both yours and the adjusted code in the comments for the forms helpful.

Code:
Option Compare Database
Option Explicit

Public Sub ChangeRecordLockReport()
'accessmvp.com/thedbguy
'7/18/2014

Dim rpt As Variant

For Each rpt In CurrentProject.AllReports
    DoCmd.OpenReport rpt.Name, acViewDesign
    Reports(rpt.Name).Report.RecordLocks = 0
    DoCmd.Close acReport, rpt.Name, acSaveYes
Next

End Sub

Public Sub ChangeRecordLockForm()

Dim FRM As Variant

For Each FRM In CurrentProject.AllForms
DoCmd.OpenForm FRM.Name, acViewDesign
Forms(FRM.Name).Form.RecordLocks = 0
DoCmd.Close acForm, FRM.Name, acSaveYes
Next
End Sub
Hi. Maybe you can apply the technique demonstrated here for your purposes. Basically, instead of .RibbonName, mabye try .RecordLocks. Just a thought...

 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:11
Joined
Oct 29, 2018
Messages
21,469
Thanks for the code. I found both yours and the adjusted code in the comments for the forms helpful.

Code:
Option Compare Database
Option Explicit

Public Sub ChangeRecordLockReport()
'accessmvp.com/thedbguy
'7/18/2014

Dim rpt As Variant

For Each rpt In CurrentProject.AllReports
    DoCmd.OpenReport rpt.Name, acViewDesign
    Reports(rpt.Name).Report.RecordLocks = 0
    DoCmd.Close acReport, rpt.Name, acSaveYes
Next

End Sub

Public Sub ChangeRecordLockForm()

Dim FRM As Variant

For Each FRM In CurrentProject.AllForms
DoCmd.OpenForm FRM.Name, acViewDesign
Forms(FRM.Name).Form.RecordLocks = 0
DoCmd.Close acForm, FRM.Name, acSaveYes
Next
End Sub
Hi. Congratulations! Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Top Bottom