Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I "lock" a control on a sSubForm from code in the Main form?

Status
Not open for further replies.

Paul7905

MIS
Jun 29, 2000
205
US
I have a Form with a Sub-form. the subform has, as it's record sourcs, a table, the data is shown in datasheet design on this subform. In this sub-form, the user is able to key values into two of the colums (two fields in each record).

I have two buttons on the "Main" form which perform a print job, one print job uses data keyed by the user in one editable column in the sub-form, the other print button uses data from the other editable column

When one of the print buttons is clicked on, in the click event procedure, I want to be able to change the property "locked" from "NO" to "YES"; preventing the user from keying data into the column after printing the report which uses the data from that column.

I found that, in the subform, if i put the statement Me!QtyTree.Locked = True that the column of data indeed changes to Locked "yes" and the data column cannot be edited by the user, this is what i want to accomplish.

when i put this same statement into the event function on the Main form for the print function, I get an error saying that the field in question cannot be found by access.

My assumption is that the "Me!......" statement is only valid for and references controls on the form in which the
statement is coded.

My question is, how can i code this "Me!QtyTree.Locked = True" statement on the main form so that it references the control on the subform ?

I know there must be a way to do this, it seems like it would not be that unusual for someone to wish to reference another forms controls.

Thanks !

(so far, I cannot believe the wonderful wealth of knowledge here and the willingness of others to share thier hard won knowledge !...... it is incredible ! )

Paul
 
Paul, use the following to access the properties collection of the sub form.

Forms![MainFormName]![SubFormName].Properties.Locked = True

have fun.
 
You can use the following to lock the QtyTree field on the subform.

Me.SubformName.Form!QtyTree.Locked = True
 
Thanks so much (i hope i am able to answer some questions here myself someday !!0)

Paul

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top