Prevent Edits on Form but Not SubForm

mamandeno

Dabbler in Access
Local time
Tomorrow, 05:24
Joined
Jan 8, 2007
Messages
30
Hi,

I have a form which shows training information for employees.

The main form shows the individual's details - name, job etc.

The subform shows the various training courses the person has completed, and the level of competency attained for each.

I want to prevent users from altering/adding/deleting the personal details recorded on the main form, but I want to allow them to edit training course records on the subform.

I have tried setting the AllowDeletions, AllowAdditions etc properties on the main form to "No", but this also effects the SubForm, regardless of what its corresponding propoerties are set to.

The only thing I can think of is to lock individual fields on the main form. Is there a simpler way? :confused:

Mike
 
I just always locked the controls when I didn't want them messed with. You can do it very easily especially if you use a Tag. That way you can lock and unlock only the ones you want locked with ease.

Code:
Dim ctl as Control

For each ctl in Me.Controls
   If ctl.Tag = "WhateverYouPutInTheTagProperty" Then
       ctl.Locked = True
   End If
Next ctl

and then you can use the reverse for an unlock button if you wish.
 
quick question; how do you lock a particular field after a different field is updated?
 
Use the afrer update event of the control displaying the field.
 
what code would you use though. this is what i tried using:

If Forms![frmConsultantList].SSN = "" Then
Forms![frmConsultantList].FedTaxID.Locked = False
Else: Forms![frmConsultantList].FedTaxID.Locked = True
End If

but after doing that, the locked field does not unlock and stays locked permanently
 
Is SSN stored as text or a number? If a number then you would need to test for null instead:
Code:
If IsNull(Forms!frmConsultantList.SSN) Then
Also, get rid of the colon after ELSE it should read
Code:
Else 
Forms!frmConsultantList.FedTaxID.Locked = True
End IF
 

Users who are viewing this thread

Back
Top Bottom