Check box to lock all fields in record (1 Viewer)

avenger619

Registered User.
Local time
Yesterday, 22:51
Joined
Jan 2, 2013
Messages
49
Hi guys,

So I would like to have a yes/no check box that can be clicked on a clients record that is being cancelled and have a promp initiated stating something like "if cancelled all fields will be locked" Yes No.

Then all fields for that applicant only will be locked.

I will create a hidden unlock button in case future I must unlock.

I have a code to lock individual fields under current event, but am trying to avoid a long list, especially with subforms that apply on record on main form too.

So I was looking for possibly a general code to lock individual applicant record and all fields/sub form fields that apply to applicant name.

can this be possible? The idea is so once a customer cancels or graduates employees cant go back and tamper with the information. There been cases were employees accidentally deleted fields or even complete records.
 

Adam Caramon

Registered User
Local time
Today, 01:51
Joined
Jan 23, 2008
Messages
822
How about something like this in the On_Current event of your form?

Code:
if me.<name of check box> = true then
        Me.Form.AllowAdditions = False
        Me.Form.AllowDeletions = False
        Me.Form.AllowEdits = False
        Me!<subformName>.Form.AllowAdditions = False
        Me!<subformName>.Form.AllowDeletions = False
        Me!<subformName>.Form.AllowEdits = False
else
        Me.Form.AllowAdditions = True
        Me.Form.AllowDeletions = True
        Me.Form.AllowEdits = True
        Me!<subformName>.Form.AllowAdditions = True
        Me!<subformName>.Form.AllowDeletions = True
        Me!<subformName>.Form.AllowEdits = True
end if
 

Sketchin

Registered User.
Local time
Yesterday, 22:51
Joined
Dec 20, 2011
Messages
575
I did something similar except I locked all of the individual controls and put it in a function called LockAllControls:

Code:
Forms![frmInvoicing]!cboInvoiceTo.Locked = True
Forms![frmInvoicing]!cboInvoiceContact.Locked = True
Forms![frmInvoicing]!InitiatedBy.Locked = True
Forms![frmInvoicing]!Project.Locked = True
Forms![frmInvoicing]!PaymentTerms.Locked = True
Forms![frmInvoicing]!InvoiceDate.Locked = True
Forms![frmInvoicing].Form![SubfrmInvoicing_items].Controls!Quantity.Locked = True
Forms![frmInvoicing].Form![SubfrmInvoicing_items].Controls!Units.Locked = True
Forms![frmInvoicing].Form![SubfrmInvoicing_items].Controls!ItemDescription.Locked = True
Forms![frmInvoicing].Form![SubfrmInvoicing_items].Controls!ItemCost.Locked = True
Forms![frmInvoicing].Form![SubfrmInvoicing_items].Controls!SubTotal.Locked = True
 

John Big Booty

AWF VIP
Local time
Today, 15:51
Joined
Aug 29, 2005
Messages
8,263
You could simplify that to;
Code:
        Me.Form.AllowAdditions = Not me.<name of check box>
        Me.Form.AllowDeletions = Not me.<name of check box>
        Me.Form.AllowEdits = Not me.<name of check box>
        Me!<subformName>.Form.AllowAdditions = Not me.<name of check box>
        Me!<subformName>.Form.AllowDeletions = Not me.<name of check box>
        Me!<subformName>.Form.AllowEdits = Not me.<name of check box>
 

avenger619

Registered User.
Local time
Yesterday, 22:51
Joined
Jan 2, 2013
Messages
49
Hey guys,

Sorry, for the late reply been fighting this nasty flu.

Thanks for the replies, I will check them out and post if they work.

This is what I found for the initial promp window which works great:

Private Sub Sold_BeforeUpdate(Cancel As Integer)
If Sold = True Then
If vbNo = MsgBox("Record will be locked. Are you sure you want to cancel?", vbYesNo) Then
Cancel = True
Sold.Undo
End If
End If
End Sub


Update, I tried the above by John Big Booty code but ran into a wall. Currently am using my Form Current Event for a "Marquee", so when I add this lock code my Marquee dont work. not sure how to setup 2 codes for one Event. Also, my Check box click is on a subform and not my Main Form. How is the code affected by this?
 

avenger619

Registered User.
Local time
Yesterday, 22:51
Joined
Jan 2, 2013
Messages
49
This is what I have but does not work: Any Ideas?

Private Sub Form_AfterUpdate()
If Form![Cancelled Program]!Sold = True Then
Me.AllowDeletions = False
Me.AllowEdits = False
Me.[Checkings Acct Query].Form.AllowDeletions = False
Else
Me.AllowDeletions = True
Me.AllowEdits = True
Me.[Checkings Acct Query].Form.AllowDeletions = True
End If
End Sub

Ok. I think I got it, seems like I must have the 3 rows (=False/ =True)so it works, not 1 like above for each subform. Since I have like 3-4 Subforms seems like it may be a long code after all.

If Form![Cancelled Program]!Sold = True Then
Me.AllowDeletions = False
Me.AllowEdits = False
Me![Checkings Acct Query].Form.AllowAdditions = False
Me![Checkings Acct Query].Form.AllowDeletions = False
Me![Checkings Acct Query].Form.AllowEdits = False
Else
Me.AllowDeletions = True
Me.AllowEdits = True
Me![Checkings Acct Query].Form.AllowAdditions = True
Me![Checkings Acct Query].Form.AllowDeletions = True
Me![Checkings Acct Query].Form.AllowEdits = True
End If
End Sub


My question now is, after check box has been clicked and all fields locked, how can I disable it so no one can uncheck it? Of course unless I do from design/admin mode.
 
Last edited:

John Big Booty

AWF VIP
Local time
Today, 15:51
Joined
Aug 29, 2005
Messages
8,263
Simply move the focus to any other control on your form, that can accept focus, then set the check box's Locked Property to True.
 

Users who are viewing this thread

Top Bottom