Have to arrow off main form to refresh subform

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

Guest

I have a main form and a subform. They are tied together with a relationship
with a field "ProjName".

When I change the ProjName on the main form, the records in the subform
disappears. I go to the next record in the main form and then go back to
that record where I made the change and then I do see the ProjName change.

Is there a way to make it so that I can change the ProjName without having
to advance to the next record and then back to the same record?

Thanks in advance.
 
This is normal. When you change the data in a linking field the related data
gets lost for a moment. If you have cascade updates set in the relationship
of you tables then the related fiields get updated when the record is saved
(which happens when you move to another record). You could save the record
without moving to another form by doing something like the following on the
main form. I beleive this will cause the updates to occur and your subform
should display the updated data. The requery may not be necessary, try
without also.

Me.Dirty = False
Me.Subform.Requery
 
Where do I type the Me.dirty = False?

Tony Vrolyk said:
This is normal. When you change the data in a linking field the related data
gets lost for a moment. If you have cascade updates set in the relationship
of you tables then the related fiields get updated when the record is saved
(which happens when you move to another record). You could save the record
without moving to another form by doing something like the following on the
main form. I beleive this will cause the updates to occur and your subform
should display the updated data. The requery may not be necessary, try
without also.

Me.Dirty = False
Me.Subform.Requery
 
You could add a Save button and add the code to the OnClick event of the
button. You could also add it to the AfterUpdate event of the ProjName
control. Keep in mind that Me.Dirty = False causes the record changes to get
committed to the table (saved) and you should make sure you actually want to
save the record. Also any code you have in the BeforeUpdate and AfterUpdate
of the form will execute.

Probably the Save button is the better choice because it gives the user a
chance to change their mind about editing the ProjName.
 
Back
Top