Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / March 2007

Tip: Looking for answers? Try searching our database.

problem with subform control references

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dick Minter - 31 Mar 2007 18:06 GMT
My form consists of a main form and two linked, embedded subforms.  The main
form source is the employee master, the first subform ("emply_bal_subform")
source is a by-year summary of allowed absences (vacation, etc), and the
second subform shows current year absences.  I've placed calculated text
boxes on subform 1 to show summary activity for the current year and balance
of unused allowances by category.  The problem:
The dsum funciton entered as a record source on subform 1 returns only a
"Name?" error.  The exact same expression placed on a command button on the
main form works as intended.  The expression as entered:

= DSum("[hours]", "absences", "[reasonCode] = 2 AND [Year] = " &
Emply_bal_Subform.Controls![Year] & " AND [emp_id] = " &
Forms!fmEmpAbsHdr.Controls!Emp_ID)

The addition of some modifiers in the expression may be unnecessary but I
was trying everything starting with the usual "me" reference, and, as
indicated, this does work when called from a command button on the form.  
I've also tested the string returned by the WHERE portion of the expression.  
Why doesn't it work on the subform control?  Can you suggest another approach?

DM
Douglas J. Steele - 31 Mar 2007 18:18 GMT
To refer to a control on a subform from the parent form, you use:

Forms!NameOfParentForm!NameOfSubformControl.Form!NameOfControlOnSubform

(You can also use Me!NameOfSubformControl.Form!NameOfControlOnSubform from
the parent form's class module)

Note that depending on how you added the subform to the parent form, the
name of the subform control may not be the same as the name of the form
being used as a subform. You must use the name of the control.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> My form consists of a main form and two linked, embedded subforms.  The
> main
[quoted text clipped - 23 lines]
>
> DM
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.