getting subform textbox value into main form

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
 
J

John Vinson

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top