Problem with VBA and assignment of a value

  • Thread starter Thread starter Steve S
  • Start date Start date
S

Steve S

I have a form w/subform and need to display the average of one field
(AverageAge) and the count of records in the subform on the form somewhere
else than in the subform. I calculate AverageAge as Average([Age] in the
form footer. I get the record count using the recordCount property o the
subform.

The problem is that I can't sem to get the value 'AverageAge' into an
unbound textbox.

Me.AvgAge = Me.Team_Members_subform.Form.AverageAge produces the error
Application-Defined or Object-Defined error.

Me.AvgAge = Me.Team_Members_subform.Form.Age gives me the correct age for
the first record in the subform which is what I expected to get.

Me.AvgAge = Me.Team_Members_subform.Form.[AverageAge] gives the error
Microsoft access can't find the field '|' referred to in your expression.

Me.AvgAge = Me.Team_Members_subform.Form!AverageAge AND
Me.AvgAge = Me.Team_Members_subform.Form![AverageAge] both
give a blank or null in the field 'AvgAge'. If I type in a number they
delete it so I know something is happening but I am not getting the value I
expect.

HELP
 
As a followup to the first post I can get the value of AverageAge from the
footer of the subform by using the following in the ControlSource property of
the testbox.

=[Team Members subform].[Form]![AverageAge]

this has worked for sometime but nowI need to control when the field gets
updated so I need to get the VBA code to work

thanks for any and all help.
 
Steve,

Is the control where you are storing the average age actually named
'AverageAge'? If not you should use the actual name of the control.

Me.Team_Members_subform.Form![name of control here]

HTH,

Chris
 
Back
Top