Allow Edits or an alternative

G

Guest

I was wondering if there is a way to programatically dissalow edits in
reports for bound controls only. I have several forms which I would like to
be read only, but to allow users to enter identifiers in fields for
searching/filtering purposes, but with AllowEdits set to false, they can only
click buttons. The general idea is to allow users to edit records by
clicking a command button - if they have the appropriate levels of access
(also determined programatically, though I've got that figured out) they will
be allowed to edit, otherwise they can just browse. It would help to reduce
accidental data errors.
 
R

Rick Brandt

Vel. said:
I was wondering if there is a way to programatically dissalow edits in
reports for bound controls only. I have several forms which I would
like to be read only, but to allow users to enter identifiers in
fields for searching/filtering purposes, but with AllowEdits set to
false, they can only click buttons. The general idea is to allow
users to edit records by clicking a command button - if they have the
appropriate levels of access (also determined programatically, though
I've got that figured out) they will be allowed to edit, otherwise
they can just browse. It would help to reduce accidental data errors.

Instead of AllowEdits you can set the Locked property of all bound controls
to Yes. When they press the [Edit] button you loop through all bound
controls in code and change the Locked property back to No.
 
G

Guest

Open the form in design mode.
Right-click on each textbox you want to lock.
Select properties.
On the Data tab change the Locked property to Yes.

jmonty
 
G

Guest

While this is certainly something I should know, I've never needed to loop
through controls in a form before. I imagine I should utilize a For...Each
statement, but what would be the context?


Something like the following?

For Each Control in frmClient
if Control.ControlSource = Null Then
Control.Locked=True




Rick Brandt said:
Vel. said:
I was wondering if there is a way to programatically dissalow edits in
reports for bound controls only. I have several forms which I would
like to be read only, but to allow users to enter identifiers in
fields for searching/filtering purposes, but with AllowEdits set to
false, they can only click buttons. The general idea is to allow
users to edit records by clicking a command button - if they have the
appropriate levels of access (also determined programatically, though
I've got that figured out) they will be allowed to edit, otherwise
they can just browse. It would help to reduce accidental data errors.

Instead of AllowEdits you can set the Locked property of all bound controls
to Yes. When they press the [Edit] button you loop through all bound
controls in code and change the Locked property back to No.
 
R

Rick Brandt

Vel. said:
While this is certainly something I should know, I've never needed to
loop through controls in a form before. I imagine I should utilize a
For...Each statement, but what would be the context?


Something like the following?

For Each Control in frmClient
if Control.ControlSource = Null Then
Control.Locked=True

What I do is enter a common string into the Tag property of all of the
controls I want to loop through.

Dim cnt as Control

For Each cnt in Me
If cnt.Tag = "MyString" Then cnt.Locked = False (or true)
Next cnt

This solves a few "gotchas". Not all controls will have a locked property
so if you just try to set it on all of them you will get an error. Also
there are times where you don;t want ot lock/unlock ALL of the controls, but
just some of them. Using the Tag property takes care of both of these.
 
G

Guest

Looks like that will do the trick.

Thanks!


Rick Brandt said:
What I do is enter a common string into the Tag property of all of the
controls I want to loop through.

Dim cnt as Control

For Each cnt in Me
If cnt.Tag = "MyString" Then cnt.Locked = False (or true)
Next cnt

This solves a few "gotchas". Not all controls will have a locked property
so if you just try to set it on all of them you will get an error. Also
there are times where you don;t want ot lock/unlock ALL of the controls, but
just some of them. Using the Tag property takes care of both of these.
 

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

Top