Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access 2010 - What Control Name do I use to Requery this Subform?

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 hereenter image description hereenter 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

like image 863
programmer Avatar asked Sep 30 '12 15:09

programmer


People also ask

How do you refer to a subform control in access?

To Access, a subform is just another control. To refer to it, use the name of the control. refers to the subfrmOrders subform on the frmCustomer form as a control. To refer to a control on a subform, use the Form property to tell Access that you are referring to the subform as a form, not as a control.

How do I requery a subform from another Form?

On the main form look at the label the subform wizard provided or select the subform by clicking once or on the border around it and look at the "caption" in the "Other" tab in properties. That's the name you use for requerying, not the name of the form that appears in the navigation panel.

Where is the subform control in access?

On the Design tab, in the Controls group, click the Subform/Subreport button. Click on the form where you want to place the subform. Follow the directions in the wizard. When you click Finish, Access adds a subform control to your form.

What is a control name in access?

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.


2 Answers

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

like image 74
Fionnuala Avatar answered Oct 11 '22 06:10

Fionnuala


The macro is one way to do it. VBA can also do this. In your case in the "onclick" event you could put the code: Docmd.Requery "ServiceSalesSubform" It does the same thing but sometimes it is nice to have everyting in VBA code. When there is a mix of code and macros it can get confusing to tell what is happening and when.

like image 22
Nigel Avatar answered Oct 11 '22 05:10

Nigel