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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locking a record from update once approve checked

Status
Not open for further replies.

idono

Technical User
Jan 16, 2002
71
US
Here is one for you all. I want to lock a record permanently after the approved checkbox has been clicked. Well maybe updatable by admin after checked. Is there such a function or do I disable all fields of the form if checked? If all fields must be disabled, is it possible to load the controls of a form into a recordset?

Open for suggestions.

Dugger
 
You'll need to disable all the controls if checked and then reenable them when necessary. Just use:

Dim ctrl as Control

For each ctrl in Me
Loop through and disable
next ctrl

You might have to tweak that a little (I would recomend checking for Text boxes, Command buttons, Combo boxes, etc before disabling as it will save you headaches - otherwise you'll be diabling labels, lines, boxes, etc)

Hope this helps, Kyle ::)
 
Here's how I do it. Every table I create gets a field called EditLock, Boolean.

The following function is added to a database module and is called in the OnCurrent event of every appropriate form. It will disable editing for the form rather than for every control. Set the field EditLock to true when you no longer want to allow editing for that record, for instance when it is approved.

I have a similar setup for DeleteLock.

Public Function SetEditLock(frm As Form)
On Error GoTo Err_SetEditLock
'toggle form edits based on whether record shouldn't be edited/deleted
If frm!EditLock Then
frm.AllowEdits = False
Else
frm.AllowEdits = True
End If

Exit_SetEditLock:
On Error Resume Next
Exit Function

Err_SetEditLock:
Select Case Err
Case 0 'insert Errors you wish to ignore here
Resume Next
Case 94, 2465
frm.AllowEdits = True
Resume Exit_SetEditLock:
Case Else 'All other errors will trap
Beep
MsgBox Err.Number & "; " & Err.Description, , "Error in function basFramework.SetEditLock"
Resume Exit_SetEditLock
End Select
Resume 0 'FOR TROUBLESHOOTING
End Function
"The Key, The Whole Key, and Nothing But The Key, So Help Me Codd!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top