Lock Current record on a 'continuous' form?


G

Guest

Hello,

I am looking for some code that will allow me to lock the current record
(i.e., prevent future changes to any fields on that record), once a
'Monitored' check box is checked.

I have some code that works great for forms that have the 'Single' instead
of 'Continuous' property set:

Public Sub LockControls(frm As Form, LockValue As Boolean)
On Error Resume Next
Dim ctl As Control

For Each ctl In frm.Controls
With ctl

Select Case .ControlType
Case acTextBox
ctl.Locked = LockValue

Case acComboBox
If ctl.Tag = 2 Then
ctl.Enabled = True
Else
ctl.Locked = LockValue
End If

I'm hoping there is some kind of 'Record.' method instead of having the code
execute to lock all controls on the current form, as it does now.

Thank you.
 
Ad

Advertisements

G

Guest

I can't think of any way to do it with a record-level lock, however it would
be REAL easy to do in code... just have an OnCurrent event (mirrored with an
AfterUpdate event for your checkbox) that simply makes the Enabled property
FALSE if your box is checked.


Richard Rost
www.AccessLearningZone.com
 
Ad

Advertisements

G

Guest

Hi Amicron,

The following code unfortunately still results in ALL records showing on the
Continuous Form as disabled once I check off the "monitored Record" checkbox.
I have this in the 'After_Update' Event of the checkbox:

Private Sub record_monitored_AfterUpdate()
Dim blnEnable As Boolean
blnEnable = (Me.record_monitored.Value <> True)
If MsgBox("Checking this box will lock this record. Is this OK", vbYesNo) =
vbYes Then
Me.conmed_number.Enabled = blnEnable
Me.conmed_drug.Enabled = blnEnable
Me.conmed_indicat.Enabled = blnEnable
Me.conmed_dose.Enabled = blnEnable
Me.conmed_unit.Enabled = blnEnable
Me.conmed_unit.Enabled = blnEnable
Me.conmed_schd.Enabled = blnEnable
Me.conmed_startdt.Enabled = blnEnable
Me.conmed_stopdt.Enabled = blnEnable
Me.conmed_cts.Enabled = blnEnable
Me.data1_init.Enabled = blnEnable
'Me.record_monitored.Enabled = blnEnable
Else
MsgBox ("Leave box unchecked until you have entered in the official,
Monitored Record")
Me.record_monitored.Value = 0
End If
End Sub

You mentioned 'mirroring' this event in the 'On Current' Event, but trying
that gave me errors. Are you saying to put the above code in the 'On
current:' Event?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top