Do not allow modifications

  • Thread starter Thread starter pammy via AccessMonster.com
  • Start date Start date
P

pammy via AccessMonster.com

If I have a complaint # field on a form and the user adds the information to
the form and moves off this record or saves it, I do not want this field to
be modified. All the other fields on the form can be changed, but not the
complaint#. Is there a way to set a property that will not allow a field to
be changed without writing any VB code? Thanks,
 
pammy said:
If I have a complaint # field on a form and the user adds the
information to the form and moves off this record or saves it, I do
not want this field to be modified. All the other fields on the form
can be changed, but not the complaint#. Is there a way to set a
property that will not allow a field to be changed without writing
any VB code? Thanks,

You had a very simple request until the last sentence. You will find that
you can;t really get very far in Access wihtout learning to use some VBA,
even if just a little bit sprinkled here and there.

All you need is a single line in the Current event of the form.

Me.TextBoxName.Locked = Not IsNull(Me.TextBoxName)

That will allow entries in the control as long as it is blank, but lock it
when it already contains an entry.
 
pammy,
Not really, you do need to write code to make a decision as to wheteher the field
should or should not be enabled.
There may/may not be a Macro function that would do it for you, but Macros are very
limited, and it's best to bite the bullet and learn to "grow your own" code for simple
functions.

Using the OnCurrent event of the form...

Private Sub frmYourForName_Current()
ComplaintNo.Enabled = IsNull(ComplaintNo)
ComplaintNo.Locked = Not IsNull(ComplaintNo) 'optional
End Sub

If you also use the same code in the AfterUpdate event of ComplaintNo... the field will
Disable immediately.
If you don't, the user (if a mistake is made) can correct it, and the control will
Disable once you leave the record, or revisit that record later.

--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
Back
Top