Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populate Age field in a form

Status
Not open for further replies.

splats

Technical User
Jan 2, 2003
131
I have two tables and a query that I would like to be on a form. the form has data from the Employee table and links to a subform DCRIncidents with data from the DCRIncidents table. On a separate query, I have an Age field calculate according to the Incident Date that is on the DCRIncidents table. I would like the Age field to also be on the subform and to automatically populate when the data is entered into the Incident Date field. The query works for this. How can I get the form to work as well? The code that I use on the query for the Age field is:

Age: DateDiff("yyyy",[DOB],[IncidDate])+Int(Format([IncidDate],"mmdd")<Format([DOB],"mmdd"))

In the suform, I have the Age field (Presently unbound) How can i link it so that it populates automatically?

Thank you
 
Hi
Create a text box on the subform and set the Control Source to:
[tt]=DateDiff("yyyy",[Forms]![Employees]![DOB],[IncidDate])+Int(Format([IncidDate],"mmdd")<Format([Forms]![Employees]![DOB],"mmdd"))[/tt]
Assuming that the main form is called Employees.
 
Hello Remou

Thank you for your suggestion. I am still not able to get this to work. In the textbox it says #Name?

Do you have any idea why?

Thank you

T
 
Hello there, I figured it out. I had the wrong name for the form. It now works like a charm. Thank you Remou
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top