Update Subform field from another Form (1 Viewer)

ted.martin

Registered User.
Local time
Today, 04:49
Joined
Sep 24, 2004
Messages
743
I have a subform which calls a new Pop-Up form. The user inserts some data into the Pop-Up form, does a calculation and I then want the calculated value to update a field on the Sub-Form.

I have tried this line of VBA (and variations) but it errors saying that the field cannot be found. I must admit, I never quite get this kind of form referencing syntax right without a lot of trial and error. If someone could explain the rationale, that would also be good.

My erroneous code is:

Forms![mainform].[subformname].[Form]!Field.value = PopUpformfield.value

I guess I could do this with an appropriate SQL statement but I was hoping this would be simpler.

Thanks
 

vbaInet

AWF VIP
Local time
Today, 05:49
Joined
Jan 22, 2010
Messages
26,374
Here we are:

Code:
Forms("mainform").Controls("subformname").Form.Controls("[COLOR=Red][B]ControlName[/B][/COLOR]").value = Popup[COLOR=Red][B]ControlName[/B][/COLOR].value
Notice it should be the name of the control, not the field.

Or using your variation:

Code:
Forms!mainform!subform[COLOR=Red][B]ControlName[/B][/COLOR].Form[COLOR=Blue][B]![/B][/COLOR][COLOR=Red][B]ControlName[/B][/COLOR].value = Popup[COLOR=Red][B]ControlName[/B][/COLOR].value
 

ted.martin

Registered User.
Local time
Today, 04:49
Joined
Sep 24, 2004
Messages
743
Your are indeed a Scholar and a Gentleman. Thank you
 

Users who are viewing this thread

Top Bottom