command buttons & controls

K

koko

in a form, i want to (step 1)lock some controls at same
time disable a command button when clicked. And
(step 2)'refresh' (unlock/enable) when i go to a new
record. furthermore,(Step 3) i want the controls/command
button of previous records to remain locked/disabled when
browsed.

the procedures below does steps 1 & 2. what do i need to
add or change so it can so it can also execute step 3.
right now, when im in a new record and did not hit the
command button before going back to previous records, the
controls/command button are also unlocked/enabled.

thanks for your help in advance.

Private Sub SOFinalizeCB_Click()
Me!PartID.Locked = True
Me!SORefNo.Locked = True
Me!SOFinalize = "Yes"
[PartID].SetFocus
Me!SOFinalizeCB.Enabled = False
End Sub

Private Sub Form_Current()
If Me.NewRecord = True Then
Me.PartID.Locked = False
Me.SORefNo.Locked = False
Me!SOFinalizeCB.Enabled = True
End If
End Sub
 
W

William Taylor

If you want to lock all existing records but be able to edit a record if it
is a new record then use code like this
Private Sub Form_Current()
Dim strFinalize as String
Me.PartID.Locked = not NewRecord
Me.SORefNo.Locked = not NewRecord
Me!SOFinalizeCB.Enabled = NewRecord
SOFinalize = IIf (NewRecord, "Yes","No")
End Sub
Private Sub SOFinalizeCB_Click()
Me.Dirty = False
End Sub
 

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