Re: dcount expression on subform

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



"JohnE" <JohnE@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A41AB00F-F24F-423C-8CB3-7287C8A74D9B@xxxxxxxxxxxxxxxx
I have a main form that has 2 subforms on it. On SubA (source object is
frmClaimProvision) there is a textbox that is to display the the number of
associated comments there are in SubB (source object is
frmClaimProvisionComment). Both subforms are in continuous style. The way
this works is that SubA is the many to the mainform one, while SubB is the
many to the SubA one. ProvisionID is the PK of tblClaimProvision and the FK
of tblClaimProvisionComment. Here is the expression that is the textbox
control source.

=DCount("ProvisionID","tblClaimProvisionComment",[ProvisionID]=[Forms]![frmClaimProvision]![ProvisionID])

This is not working and I am lost on what is missing or how to proceed from
here so I seek assistance. Can anyone help? Thanks in advance for
responding.

Subforms are not technically "open" and are not found in the Forms Collection.
You have to reference them via the main form and subform control object.

=DCount("ProvisionID","tblClaimProvisionComment",[ProvisionID]=[Forms]!ParentFormName!SubA.Form![ProvisionID])

Note that the name of the subform source object is not used at all. What you
refer to is the Form property of the Subform Control

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


.



Relevant Pages

  • Re: changing subform source object
    ... the SourceObject of the subform will be a different query. ... I've created a form, frmResults, which has various command buttons in the ... frmResultsSub is set with an unbound Source Object. ... I initially thought above a public variable (strSource) but I don't know ...
    (microsoft.public.access.formscoding)
  • Re: Subreports - displaying options
    ... In your answer to Malcolm you mentioned a solution using the Source Object. ... > the Visible property of each Control in the Form embedded in the Subform ... >> Name of the report is Client Bill Final LOGO ...
    (microsoft.public.access.reports)
  • Re: Enter Parameter Value on a subform
    ... Doug Steele, Microsoft Access MVP ... shows the source object as "2ResponseFormB" and the name as ... I asked whether you were certain that the name of the subform control on ...
    (microsoft.public.access.forms)
  • Re: changing subform source object
    ... frmResults what to display in its sunform. ... the subform control's SourceObject: ... frmResultsSub is set with an unbound Source Object. ... I initially thought above a public variable (strSource) but I don't know ...
    (microsoft.public.access.formscoding)
  • RE: "Data type mismatch" error
    ... Clifford, I do not receive the error anymore. ... For the Source Object value of my main form, ... my default subform anyways. ... and then run the query while the frmSchedules form is ...
    (microsoft.public.access.formscoding)