Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lock a record based on the contents of a field 1

Status
Not open for further replies.

beverlee

Instructor
Oct 8, 2002
61
US
I have a database for Pretrial Bail Release Supervision. Once the case is closed, a [CaseClosedDate] will be entered in the form. As soon as that field is no longer empty, I would like the record to become read-only. They have other cases (records), however, that need to remain unlocked. I have tried placing code on the AfterUpdate event of the CaseClosedDate field and on the OnCurrent event of the form but am having no luck. Any suggestions?

Thanks!!
 
If this is a continuous form, Conditional Formatting may help. If not, it is best to post your code.
 
How are ya beverlee . . .

In the [blue]OnCurent[/blue] event of the form:
Code:
[blue]   If IsDate(Me![purple][b]CaseClosedDate[/b][/purple]) Then
      Me!AllowEdits = False
   Else
      Me!AllowEdits = True
   End If[/blue]

Calvin.gif
See Ya! . . . . . .
 
If your form is not continuous then this should work:

Code:
Private Sub Form_Current()
     If IsNull(Me.CaseClosedDate) Then
          Me.AllowEdits = True
     Else
          Me.AllowEdits = False
     End If
End Sub

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Meant to add the caveat, that applies to both my solution and that of the venerable Aceman1, that you need to think about how you're going to correct a record once the closed date is entered. And sooner or later, you are going to have to correct a closed record!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Thanks....both solutions worked. I had already thought about the fact that sometime a closed record will probably need to be changed. Maybe I will change the trigger to a checkbox of some kind.

One other little glitch. It is working perfectly for the main form itself, but I have a couple of related continuous subforms that will also need to be locked. They are currently still allowing edits.
 
In the same Sub Form_Current() for your main form you need to add the AllowEdits = True and the AllowEdits = False for the each subform.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
beverlee said:
[blue]I had already thought about the fact that sometime a closed record will probably need to be changed. [purple]Maybe I will change the trigger to a checkbox of some kind.[/purple][/blue]
[purple]Perhaps a set of macro hotkeys will do for this?[/purple]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top