Help needed - Recalc on subform.

F

FatMan

Hi all:
I have a form with a subform on it. I would like to know how I could cause
the subform to recalculate when a control on my main form has been updated.

The main form name is: frmSprayRec09Add
The control that is been updated is: txtDate
The name of the subform is: tblProducts subform

I have tried entering me.recalc in the "after update" event on the control
txtDate but this only causes the main form to recalculate. How do I
reference the subform and cause it to update?

All help is greatly appreciated.

Thanks,
FatMan
 
F

FatMan

BruceM:
Thanks for the reply. Now that you ask the question….nothing has changed on
my subform at all. On the subform is a control named: Earliest_Harvest_Date
that is calculated as:

Me.Earliest_Harvest_Date = Me.DaysToHarvest + 1 +
Forms!frmSprayRec09Add.txtDate

What my overall goal is to have Earliest_Harvest_Date recalculate if and/or
when the user makes a change to the text box txtDate.

So I guess what I really need to know is how to reference the
Earliest_Harvest_Date control on my subform.

Keeping in mind:
The main form name is: frmSprayRec09Add
The name of the subform is: tblProducts subform
The control that is been updated is: txtDate

Can you help me?

Thanks,
FatMan
 
B

BruceM

In general, to reference a control on the subform you first need to
reference the form property of the subform control, which is the "box"
containing the subform. The name of the subform control is not necessarily
the same as the subform itself. Check by going to design view of the main
form, then clicking the edge of the subform. When the box around the
subform is selected, click View >> Properties and check its name.

Anyhow, the syntax is:

Forms!frmSprayRec09Add![tblProducts subform].Form!Earliest_Harvest_Date

In the main form's code module you could probably use shorthand:

Me.[tblProducts subform].Form.Earliest_Harvest_Date

Note that the brackets are needed if there is a space in the control name.
Note too that you need to use the exclamation marks (bangs) in the long
notation. In the short notation you can use it as written, or:

Me![tblProducts subform].Form!Earliest_Harvest_Date

For more about bangs and dots:

http://my.advisor.com/doc/05352

You seem to be adding DaysToHarvest, which I assume is a number, plus 1 to a
date. As a guess, you are adding days to the date a spray was applied, and
using the result as the earliest you can harvest the sprayed crops. Check
out help for information about the DateAdd function, which gives you more
control over date calculations.

Your use of the term "SprayRec09" makes me wonder if you have a separate
table for each year. If so, your design could use some improvement so that
you don't need a new table each year. The good news is it may not be all
that difficult to redesign. It could be a matter of using the proper query.
 

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