Filling in a textbox based on values from other text boxes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form where the user enters different values into 7 different
textboxes. There is an 8th text box that I would like to automatically
display the sum of the values from the first 7. I have tried making the
textbox's default value :
=Sum([TblMonthlyAssess]![Eligible]+([TblMonthlyAssess]![Ineligible]+ etc....,
I've also tried to requery the textbox using the OnEnter event, but neither
one works. I'm not very familiar with coding at all, so I'm sure I'm just on
the wrong track here, but I can't figure it out. Any help is appreciated!
 
Hi Tara

The Sum function works across the same field in multiple records, not
multiple fields in the same record.

Set the ControlSource (not Defaultvalue) of your 8th textbox to:

=Nz([NameOfTextbox1],0) + Nz([NameOfTextbox2],0) + ...

The Nz function will cause any null (blank) textbox to be treated as zero.
 
Thanks Graham. I'm still not getting what I need though. Now, it shows an
error of #Name? in the box. Here's the function as written:
=Nz([TblMonthlyAssessDekalb]![SCREENS:OtherHFISite])+Nz([TblMonthlyAssessDekalb]![SCREENS:EligibleForFollow-up(hosp)])+Nz([TblMonthlyAssessDekalb]![SCREENS:EligibleForFollow-up(WIC)])+Nz([TblMonthlyAssessDekalb]![SCREENS:AllenCountyAccepted])+Nz([TblMonthlyAssessDekalb]![SCREENS:DuplicateHospital])+Nz([TblMonthlyAssessDekalb]![SCREENS:DuplicateWIC])+Nz([TblMonthlyAssessDekalb]![SCREENS:DuplicateOTHER])+Nz([TblMonthlyAssessDekalb]![SCREENS:IneligibleHospital])+Nz([TblMonthlyAssessDekalb]![SCREENS:IneligibleWIC])+Nz([TblMonthlyAssessDekalb]![SCREENS:IneligibleOther]).

What did I miss? Also, after this is calculated, I need to save it in the
table. How do I accomplish that since the ControlSource has changed?

Thanks for any more help you can offer!

Graham Mandeno said:
Hi Tara

The Sum function works across the same field in multiple records, not
multiple fields in the same record.

Set the ControlSource (not Defaultvalue) of your 8th textbox to:

=Nz([NameOfTextbox1],0) + Nz([NameOfTextbox2],0) + ...

The Nz function will cause any null (blank) textbox to be treated as zero.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Tara said:
I have a form where the user enters different values into 7 different
textboxes. There is an 8th text box that I would like to automatically
display the sum of the values from the first 7. I have tried making the
textbox's default value :
=Sum([TblMonthlyAssess]![Eligible]+([TblMonthlyAssess]![Ineligible]+
etc....,
I've also tried to requery the textbox using the OnEnter event, but
neither
one works. I'm not very familiar with coding at all, so I'm sure I'm just
on
the wrong track here, but I can't figure it out. Any help is appreciated!
 
Never mind about the #Name? error. I figured that out and everything is
calculating fine. Also, I guess I don't really need to save this value in
the table since it will just calculate through a query if I need it to.
Thanks for your help!!
Tara said:
Thanks Graham. I'm still not getting what I need though. Now, it shows an
error of #Name? in the box. Here's the function as written:
=Nz([TblMonthlyAssessDekalb]![SCREENS:OtherHFISite])+Nz([TblMonthlyAssessDekalb]![SCREENS:EligibleForFollow-up(hosp)])+Nz([TblMonthlyAssessDekalb]![SCREENS:EligibleForFollow-up(WIC)])+Nz([TblMonthlyAssessDekalb]![SCREENS:AllenCountyAccepted])+Nz([TblMonthlyAssessDekalb]![SCREENS:DuplicateHospital])+Nz([TblMonthlyAssessDekalb]![SCREENS:DuplicateWIC])+Nz([TblMonthlyAssessDekalb]![SCREENS:DuplicateOTHER])+Nz([TblMonthlyAssessDekalb]![SCREENS:IneligibleHospital])+Nz([TblMonthlyAssessDekalb]![SCREENS:IneligibleWIC])+Nz([TblMonthlyAssessDekalb]![SCREENS:IneligibleOther]).

What did I miss? Also, after this is calculated, I need to save it in the
table. How do I accomplish that since the ControlSource has changed?

Thanks for any more help you can offer!

Graham Mandeno said:
Hi Tara

The Sum function works across the same field in multiple records, not
multiple fields in the same record.

Set the ControlSource (not Defaultvalue) of your 8th textbox to:

=Nz([NameOfTextbox1],0) + Nz([NameOfTextbox2],0) + ...

The Nz function will cause any null (blank) textbox to be treated as zero.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Tara said:
I have a form where the user enters different values into 7 different
textboxes. There is an 8th text box that I would like to automatically
display the sum of the values from the first 7. I have tried making the
textbox's default value :
=Sum([TblMonthlyAssess]![Eligible]+([TblMonthlyAssess]![Ineligible]+
etc....,
I've also tried to requery the textbox using the OnEnter event, but
neither
one works. I'm not very familiar with coding at all, so I'm sure I'm just
on
the wrong track here, but I can't figure it out. Any help is appreciated!
 
Back
Top