Protecting fields - Form(indexNo)

  • Thread starter Thread starter JK
  • Start date Start date
J

JK

Hi,

Quite often I need to protect the details part of a form from changes, yet
allowing users to have a look at it. eg. Invoice which has been invoiced -
thus no changes can be made any longer. The protection is in the details
part of the form - The Form header has a combo which search for Invoices,
therefore turning off the AllowEdits will turn off the search

Until now I simply used the WITH for each field. eg:

With Payee_ID
.ForeColor= vbWhatever
.Locked=True
.Enabled=False
End with

With Inv_Date
.ForeColor= vbWhatever
.Locked=True
.Enabled=False
End with

etc.


This is quite tedious as I need to do in many forms. Is that an easier way
of doing it?

I tried the Form(FileldIndexNumber) function to see whether I can use the
For Next but I can make no sense how the FieldIndexNumbers are allocated.
Form(0).Name gives me a filed in the header, Form(7) gives me a label which
belongs to a field in the details section *but* this is not the control
name for of that label.

Can anyone help me there in:
1. What is the index number in Form(Index), regardless of my problem.
2. Is there a better way (then the "With" Statement) of going through the
fields in the form to protect (or unprotect) them?

TIA

Regards/JK
 
Take a look at Access HELP about Collections and the For Each... function.
I seem to recall an example using For Each ... that shows how to have Access
cycle through each control, check for what type it was (combo box, text box,
label, ...), and set visible or enabled or bold or ... other properties.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Thank Jeff,

No salvation in HELP (what else is new ;-), not at least on first sight. I
am aware of the For Each statement but have never used it. I'll give it a
shot and report back.

Appreciate
Jacob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top