getting subform textbox value into main form

  • Thread starter Thread starter PM
  • Start date Start date
P

PM

This is something very simple but I am just out of touch
with proper VBA commands.

I have developed a form with a sub-form. Where Main form
requires to calculate value for AGE text boxe based on
value of DOB text box which is in subform. How do I do
this?

thanks
 
This is something very simple but I am just out of touch
with proper VBA commands.

I have developed a form with a sub-form. Where Main form
requires to calculate value for AGE text boxe based on
value of DOB text box which is in subform. How do I do
this?

Ummm... typically a subform would have many records for each mainform
record. How do you determine WHICH record?

If there's only one record, or if you want to display the age of the
currently selected record on the subform, use an expression:

=DateDiff("yyyy", Me!subformname.Form!txtDOB, Date()) -
IIF(Format(Me!subformname.Form!txtDOB, "mmdd") > Format(Date(),
"mmdd"), 1, 0)

where subformname is the name of the Subform Control (which might not
be the same as the name of the form within that control).
 
Back
Top