Solved Update a subform (1 Viewer)

zelarra821

Registered User.
Local time
Today, 15:18
Joined
Jan 14, 2019
Messages
803
Good Morning.

I am trying to update a subform by changing a value in a field of the main form.

What I do is, after updating the main form field, execute an UPDATE of the table in VBA, and I want it to update the summation.

I leave you the database. I have hidden everything but the two forms involved. In them, I have marked in red the two fields that need to be updated when changing the main field. I have also left the two tables visible. And in VBA I have put the code I am referring to at the top of the form code.

Let's see if someone can help me.

Thanks.
 

Attachments

  • Database.accdb
    2.4 MB · Views: 81

sinavere

New member
Local time
Today, 15:18
Joined
Jan 28, 2021
Messages
8
I didn't download your database, but have come across a similiar situation in the past. I found a quick an easy solution was just to close and reopen the mainform after updating info.
There is probably a better solution though
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:18
Joined
May 7, 2009
Messages
19,169
what is the formula of Beneficio on the subform?
 

zelarra821

Registered User.
Local time
Today, 15:18
Joined
Jan 14, 2019
Messages
803
Have you seen the code? I have it in a query, from where I take the value to put it in the subform through an UPDATE.
 

zelarra821

Registered User.
Local time
Today, 15:18
Joined
Jan 14, 2019
Messages
803
If I update the subform by Me! FPresupuestosSubformulario.Form.Requery, just me updated once.
 

zelarra821

Registered User.
Local time
Today, 15:18
Joined
Jan 14, 2019
Messages
803
I have shown you the query where the formula is. But as I told you, with VBA I pass that value to the table
 

Attachments

  • Database.accdb
    2.4 MB · Views: 80
  • ScreenShot001.jpg
    ScreenShot001.jpg
    551.7 KB · Views: 65
  • ScreenShot002.jpg
    ScreenShot002.jpg
    313.9 KB · Views: 68

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:18
Joined
May 7, 2009
Messages
19,169
yes it can, check the Afterupdate event.
 

Attachments

  • Database (2).accdb
    1.9 MB · Views: 98

zelarra821

Registered User.
Local time
Today, 15:18
Joined
Jan 14, 2019
Messages
803
I've already made it work. You have changed the code, and that cannot be touched, because it is the one in the subform, not the one in the main form. If I leave it as you have put it, it changes all the values.

Be that as it may, thank you very much.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:18
Joined
May 7, 2009
Messages
19,169
You only need to update the Beneficio field.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 10:18
Joined
Feb 19, 2002
Messages
42,970
If changing a field on the parent record forces an update of all child records, then the field is in the wrong table. The field should be in the parent table ONLY and not in the child table.
 

Users who are viewing this thread

Top Bottom