Access subform from a different form.

Chunk

Registered User.
Local time
Today, 18:58
Joined
Oct 25, 2004
Messages
64
I have posted about this before andhave done some reading, but cant get it working no matter what I do.

I have the following forms:

SuppierOrderCreateNew
SupplierOrderCreateNewSubForm

Obviously "SupplierOrderCreateNewSubForm" is a sub forms on "SupplierOrderCreateNew".

There is a text box on "SuppierOrderCreateNew" called "supplierOrderNumber".

There is a text box on "SuppierOrderCreateNewSubForm" called "productNumber".

I then have a second form: "ProductSuppliers". I want to return a value from "ProductSuppliers" when a button is clicked on. When the button is clicked on, I want to put the value into "productNumber". However, I dont know how to refer to the text box.

I can put the value into "supplierOrderNumber" but not into "productNumber".

Can anyone help?

I have tried:

Forms![SuppierOrderCreateNew]![SupplierOrderCreateNewSubForm].Form![productNumber] = 10

But it doesnt seem to work.

Note: 10 is not the value I want to put into the textbox, its only a random value ive been using to test the statement with.

Thanks.
 
Is "SupplierOrderCreateNewSubForm" the name of the subform control on form "SuppierOrderCreateNew"?
 
DALeffler said:
Is "SupplierOrderCreateNewSubForm" the name of the subform control on form "SuppierOrderCreateNew"?

It is a subform within the "SuppierOrderCreateNew" form yes, if thats what you mean. Im a little confused by the question.

"SupplierOrderCreateNewSubForm" is a sub form on "SuppierOrderCreateNew". Yes. :)
 
Open the mainform in design view. Click on the subform control to select it. Look in the Properties list for the name of the subform control. That's the name that needs to go in:

Forms![SuppierOrderCreateNew]![subformControlName].Form![productNumber] = 10
 
DALeffler said:
Open the mainform in design view. Click on the subform control to select it. Look in the Properties list for the name of the subform control. That's the name that needs to go in:

Forms![SuppierOrderCreateNew]![subformControlName].Form![productNumber] = 10

Ok, ill give it a try and see what happens. Thanks.
 
Works great thanks. Only problem I have now is when the user clicks on the button to put the data into "productNumber".

Every time the button is clicked on I want a newrow to be created in the sub form. Thesub form is in tabular form. Every time the button is clicked I want the value to be put into a new row.

How can I do this?
 
Just before your code writes to the subform, try:

Forms![SuppierOrderCreateNew]![subformControlName].SetFocus
DoCmd.GotoRecord ,,acNewRec
 
Last edited:

Users who are viewing this thread

Back
Top Bottom