• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 54
  • Last Modified:

How to refresh/requery a subform to show newly added record?

I have a form with an unbound combo box that is used to filter a subform.  When I add a record in the subform and hit enter, I'd like the subform to show the new record automatically.  

Right now I can only see the new record if I go back to the main form and select an option from the combo box again.

I've tried, in the AfterUpdate event of a control on the subform:
Me.Requery
Me.Refresh
Me. Dirty = false
Also tried some longer versions of requery specifying the names of the forms:  i.e. Forms!mainformname!subformname.Form.Requery

Can someone help me with the right code?
0
fabi2004
Asked:
fabi2004
  • 3
  • 3
1 Solution
 
PatHartmanCommented:
Are you saying that when you add a record to the subform, you want the RowSource of the combo to update to reflect the new record?

If that is the situation, then you have to requery the combo in the AfterUpdate event of the subform.  The subform isn't saved until the subform's AfterUpdate event runs.

Then you would use:

Me.Parent.cboWhatever.Requery
0
 
fabi2004CIOAuthor Commented:
Thank you.  I was requerying the subform instead of the control.
0
 
PatHartmanCommented:
You're welcome.  But, you still need to wait until the FORM's AfterUpdate event.  The subform record hasn't yet been saved when you do the requery in some random control on the subform.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
fabi2004CIOAuthor Commented:
Right.  So I put this "Me.Parent.cboWhatever.Requery" in the SubForm's After Update Event and it triggers when I move to a different record on the subform or when I hit "enter".  Right?
0
 
PatHartmanCommented:
Yes.  Or if you have a save button or if you click into the main form. Access is obsessed with saving your data.
0
 
fabi2004CIOAuthor Commented:
"Access is obsessed with saving your data."  ha!  That's a good thing - mostly.

Thanks for your help Pat.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now