Avatar of DCRAPACCESS
DCRAPACCESS

asked on 

Open form, sub form, control

Hi Experts.

I have a form with a subform and in the sub form there is a control, where i need to change the value.

The code is running from a Public Function in a Module.

Can some one help with this?
Microsoft Access

Avatar of undefined
Last Comment
mbizup
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of DCRAPACCESS
DCRAPACCESS

ASKER

I get a error when i try this:
MsgBox Forms!DCDK_ReportingInfo.Ekstra_reporting.Form.Controls(ctlname).Value

Also this give an error:
MsgBox Forms!DCDK_ReportingInfo.DCDK_ReportingInfo_ER.Form.Controls(ctlname).Value

"Ekstra_reporting" is the sub form name, the sub forms object name is "DCDK_ReportingInfo_ER".

The control name comes from a string ("ctlname").
Avatar of mbizup
mbizup
Flag of Kazakhstan image

What is the exact error?
Avatar of DCRAPACCESS
DCRAPACCESS

ASKER

It should be something like this, but can't get it to work:
Forms!Mainform!Subform1.Form!ControlName
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

You should not use the subform name anywhere in the command.(except by coincidence)

The subform reference needs to be the name of the subform container control on the main form.

Forms!mainformname!subformcontainercontrolname.Form!controlname
Avatar of DCRAPACCESS
DCRAPACCESS

ASKER

Sorry, my bad! I was referring to the wrong sub form name :-( Sorry for wasting every ones time mbizup wrote the right answer in the first response.
Avatar of mbizup
mbizup
Flag of Kazakhstan image

No trouble.  The distinction Pete made is an important one, and I was lazy in my post. The name of the subform control is what is needed. That is the Name property of the 'frame' that houses the subform. It is frequently the same as the subform name, but not always.
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo