how can i edit a subform if it is not allowed on the main form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a main form that does not allow edits but i want the subform to allow
edits but each time i set the main form to not allow edits, it prevents any
entries on the subform for that record
 
That's right. If the main form's AllowEdits is No, you cannot edit any of
its controls, including the subform control.

Instead, set the Locked property of the individual bound controls on the
main form, and don't lock the subform control. You will then be fine.

For an example of how to loop through all the controls on the main form and
set the Locked property, see:
Locking bound controls on a form and subforms
at:
http://allenbrowne.com/ser-56.html

The code does lock the subform as well, unless you specify it as an
exception. For example, if you subform control is named Sub1, you would
leave the subform unlocked with this code:
Call LockBoundControls(Me, True, "Sub1")
 
Allen Browne said:
That's right. If the main form's AllowEdits is No, you cannot edit any of its
controls, including the subform control.

Instead, set the Locked property of the individual bound controls on the main
form, and don't lock the subform control. You will then be fine.
[snip]

Another option is to set the RecordSourceType of the main form to Snapshot which
will make it ReadOnly.
 
Thanks very much, it was very helpful

Rick Brandt said:
Allen Browne said:
That's right. If the main form's AllowEdits is No, you cannot edit any of its
controls, including the subform control.

Instead, set the Locked property of the individual bound controls on the main
form, and don't lock the subform control. You will then be fine.
[snip]

Another option is to set the RecordSourceType of the main form to Snapshot which
will make it ReadOnly.
 
setting the locked property of the bound control to yes then prevents me from
adding records though?
 
So you want to unlock them in the Current event of the form if the form's
NewRecord property is True.
 
Yes i wish to add records to the main form and on exit have those records
then locked so they cannot be edited at a later date but at the same time
need the subform to be editable at all times
Thanks
 
Allen's response was a HOW not a question.

In the OnCurrent event of the main form place the code

if NewRecord then
me.field1name.locked = false
etc
endif

Now how do they fix mistakes AFTER they have gotten off of the record
and the bad information has been saved and the record is no longer a
new record?

Ron
 
Correction, that should be:

if me.NewRecord then
me.field1name.locked = false
etc
endif

Ron
 
Back
Top