Locking specific records

J

JenK

I was wondering if it is possible to lock records. What I mean by this is
that I would like to be able to enter in an order and then once the entry is
commpleted they can not change the supplier. How do I accomplish this?
 
G

Gina Whipp

JenK,

I would suggest some other trigger but yes this is possible by placing the
below in After Update event of the Supplier combo box??

Me.AllowEdits = False

However, the reason I suggest another trigger is... suppose I pick the wrong
Supplier? Do I have to enter a new Order?

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
 
S

Sean Timmons

Depending on what you would like to use as your trigger, you can do, say,

Private Sub Order_Button_Click()
Supplier.Enabled = False
End Sub

And include an additional

Private Sub Form_Current()
Supplier.Enabled = True
End Sub

to reset the Supplier to editable on a new record.

:
 
K

Ken Sheridan

The problem with that is that, because the control's Enabled property is set
to true in the form's Current event procedure, all a user needs to do to
change a supplier is to navigate back to an existing record. All that's
needed is the following in the form's Current event procedure:

Me.Supplier.Enabled = Me.NewRecord

and in the Form's AfterInsert event procedure:

Me.Supplier.Enabled = False

to cater for a user explicitly saving the record without navigating away
from it. Its still rather inflexible, however, if a user finds that they've
mistakenly entered the wrong supplier. Its not difficult for a reasonably
informed user to edit the row in the table by other means of course, but if
we ignore that possibility, I'd be inclined to require the user to confirm
the saving of the record. The following code is from a form's module is a
simple example of how the use of a command button and confirmation dialogue
to save a record can be forced:

Option Compare Database
Option Explicit

Dim blnSaved As Boolean

Private Sub cmdSave_Click()

Const MESSAGETEXT = "Save record?"

If MsgBox(MESSAGETEXT, vbQuestion + vbYesNo, "Confirm") = vbYes Then
blnSaved = True
On Error Resume Next
RunCommand acCmdSaveRecord
If Err <> 0 Then
blnSaved = False
End If
End If

End Sub


Private Sub Form_BeforeUpdate(Cancel As Integer)

If Not blnSaved Then
Cancel = True
End If

End Sub

Private Sub Form_Current()

blnSaved = False

End Sub


Private Sub Form_Error(DataErr As Integer, Response As Integer)

Const IS_DIRTY = 2169

If DataErr = IS_DIRTY Then
Response = acDataErrContinue
End If

End Sub

Ken Sheridan
Stafford, England
 
Top