Update a form field from a subform's field?

T

thefourthwall

Hello,

Am working with a form which shows client information, and a subform
that shows client family information.

The goal is to have a field in the main form which merely repeats one
field in the subform -- the "Total Number of Family Members."

That field is manually updated by volunteers (this is for a food
pantry) and it seemed useful to have the 'total number in family'
information to be repeated in an unbound field under the client's name:
a visual "reminder" to verify with the client the information in the
database.

Ideally the main form's field updates when the subform's field value
changes.

Main form is frmClients and subform is ClientFamilyMembers (I realize
the lack of consistency in naming: I've been doing this all of about a
month now).

The code written so far is:
Private Sub FamilyNumTotal_LostFocus()
Forms![frmClients1]!TotFamNum.Value = Me.FamilyNumTotal
End Sub

Any help you can provide is appreciated.

-thefourthwall
 
T

TonyT

Hi,

I would use the AfterUpdate event rather than the LostFocus (code only
happens if value changes);

Private Sub FamilyNumTotal_AfterUpdate()
Forms!frmClients1.TotFamNum =
Forms!frmClients.ClientFamilyMembers.Form.FamilyNumTotal
End Sub

Me.FamilyNumTotal should be fine on it's own, but just to make sure it will
work from either form.

TonyT..
 

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