Ms-access – Access 2010 – What Control Name do I use to Requery this Subform

ms-accessms-access-2010

I am now learning MS Access and I have run into a problem. I have found similar questions but after trying them I still can't figure this out.

I have added a button on a form that updates a table behind a subform and I now need that subform to display the new data. Can anyone tell me what to use as the Control Name or if I'm even on the right track to get what I want?

My main form is "EnterEmployeeSales" and my subform is "RetailSalesSubform".

Here are some screen shots of what I'm trying to do:

enter image description here
enter image description here
enter image description here

EDIT: I figured it out. I was making it TOO COMPLICATED!

I kept trying to enter stuff like "Forms!Yadda!Yadda" but all I needed to enter was the subform control's name only into the Requery "Control Name" field on my screen shot above. Imagine that! Here is a screenshot on how to determine the subform control's name (for other loser noobs like me):
enter image description here

Best Answer

There are two parts to a subform, the subform control and the form contained. It is important to use the name of the subform control to requery, not the name of the form contained. So:

 Forms!MyMainForm!MySubformControlName.Form.Requery

Or when writing code in the form module:

 Me.MySubformControlName.Form.Requery

An advatage of using Me in the form module is that intellisense will give you the name of the subform control.

More information: http://access.mvps.org/access/forms/frm0031.htm

Related Topic