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:
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):
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.
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.
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.
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With