Re: Using DoCmd.OpenForm method with a mainform and subform

Tech-Archive recommends: Fix windows errors by optimizing your registry



Open the form normally (not read-only.)

Loop through the controls on the main form, setting their Locked property to
Yes, so they cannot be changed.

Use the Current event of the subform to loop through its controls, and set
Locked to Yes unless Me.NewRecord is true.

For an example of how to loop through the controls of a form, see:
Locking bound controls on a form and subforms
at:
http://allenbrowne.com/ser-56.html
Note that the article is doing something different from what you need, but
should serve as a demo of how to determine which controls have a Locked
property to set (e.g. labels and lines do not.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"John S. Ford, MD" <johnsfordNOSPAMmd@xxxxxxxxxxx> wrote in message
news:%23kazBfdUGHA.5808@xxxxxxxxxxxxxxxxxxxxxxx
I'm using DoCmd.OpenForm to open a mainform and its subform using a WHERE
statement from a command button on another form:

DoCmd.OpenForm "frmMainForm", , , WHERE statement, acFormReadOnly

I want the user to only to be to read the record in the mainform without
editing or adding a new record.

However, I want the SUBform to be in acFormAdd that is I want my user to
be
able to read the previous records in the subform using the navigation
buttons and be able to add new records.

How can the datamode argument of the OpenForm method be different for the
Mainform and the subform?

John


.


Quantcast