If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Unanswered: Record Locking / Enabling

I have a table which has a large number of fields in it. A form which the table is inputted into through has a number of pages to it. One of the fields is called Archive. The answer is either Yes/No.

When the check box is ticked yes. I want every text box/combo box for that record to be disabled so that they can not enter details in the boxes but the data can still be seen. I have toyed with doing VBA code and it will work as i've done this in the past to make boxes visible or not. The only thing with this is that there are a large number of fields and I just wondered if there was a quicker way of Enabling or disabling the whole record on the form or not.

Because you already have a Yes/No field named Archive, You can obviously use this field to determine whether or not the record should be Locked (which is apparently what you intend). If Archive is checked (Yes) then the Record should be locked. If Archive is unchecked (No) then the Record should be Unlocked.

Note: The Archive field can be either visible or not visible.

Place this line of code into the OnCurrent event of the Form displaying your records:

Me.Locked = Me.Archive.Value

If you have a SubForm in your main form and you only want to lock that specific SubForm then place this line of code into the OnCurrent event of the main Form displaying your records:

Public Function LockAllRecords(Frm as Form, OnOff As Integer )
'if OnOff = 0 then Unlocked | If OnOff = 1 then Locked.
Dim Ctrl As Control
On Error Resume next
For Each Ctrl In Frm.Controls
Ctrl.Locked = OnOff
Next Ctrl
End Function