Referencing a calculated field in a form from a subform

J

Joanne

I have a form (frmEmployeeVacations) and a subform(sfrmTotalDays). In the
main form there is a field called txtTotalOLP which calculates each
employee's total vacation days. I would like to reference this number in the
main form from the subform, but I'm not sure how to do that. If you could
just point me in the right direction, I would greatly appreciate it.
 
J

Jeff Boyce

Joanne

If I understand your situation, you want a subform to check up on its
'parent' ... why? Much more commonly, a main form (i.e., a 'parent' form)
will display some summary data about the records displayed in the subform.

If your main form displays the employee's total vacation days, why are you
trying to "put" that value in the subform?

More info, please...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

Joanne

Hi,
Well, the way I set up the main form is that there is one record per
employee. On the main form, there is personal information i.e. address, phone
number, employee number, as well as a field called "Total OLP Days allowed".
This is a calculated field with VBA code behind it. Employees accrue OLP days
based on time that they have been with the firm and other considerations. So
my VBA code does that calculation and puts it in the field. Say Jane Doe has
a total of 30 OLP days.
Then there is a subform that lists the time taken. Each row in the subform
shows a vacation request. If Jane Doe requests Aug1 and Aug2 off, at the end
of the row it calculates 2 days. In the footer of the subform there are two
calculated fields. One of them calclulates how many days Jane Doe has taken
and the other calculates how many she has left. This last one is the one I
need to refer back to the "Total OLP Days allowed" calculated field in the
main form, since each employees total is different. Thanks and I hope I made
this clearer.
 
J

Jeff Boyce

Joanne

If I'm understanding your description, the OLP days remaining is not
determined by a single "leave" row, but by the total of all the leave rows.
If that's true in your situation, then why not put another unbound field in
the main form to show "Remaining OLP days"?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

Joanne

Thanks anyway for your help. There really are reasons that I wanted to do it
this way. I just hoped that someone could tell me how!
 
J

Jeff Boyce

Joanne

Knowing how and doing are independent of each other...

Have you looked into the .Parent property? It may be that you can, from
within the subform, use .Parent to refer to the subform's ..., well,
"parent" (i.e., the main form) and to a field thereon.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

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