473,659 Members | 3,031 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Requery Subform upon clicking a button in the main form.

1 New Member
I want to update the subform upon clicking a button (Run) in the main form. The Run button on the main form is updating a query(Filter Region). This query is the Source Object of the Subform.

The query is getting updated upon clicking the Run button but the Subform is not. The code written for the Run button on the main form is:

Private Sub Run_Click()
DoCmd.OpenQuery "Filter Region", asViewNormal, acReadOnly
End Sub

I think, by modifying the code of the 'Run' button we can update the subform.
Please suggest.
Dec 14 '15 #1
2 5490
mbizup
80 New Member
Try adding a line of code to your sub, after the OpenQuery. The general syntax for a main form requerying a subform is:

Expand|Select|Wrap|Line Numbers
  1. Me.MySubformControlName.Form.Requery
Where MySubformContro lName is the name property of the control that houses your subform (in the main form's design view). This is usually, but not always the same as the name of the subform as seen in the navigation pane/database window.
Dec 14 '15 #2
jforbes
1,107 Recognized Expert Top Contributor
In this case, the SubForm is calling the Query and displaying the Results, so you'll want to tell the SubForm to get the latest results. Something like this should work for you.
Expand|Select|Wrap|Line Numbers
  1. Me.NameOfSubForm.Form.Requery
You'll need to replace the NameOfSubForm with the real name of the Control that contains the SubForm. ...It really needs to be the Controls name.
Dec 14 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
8308
by: chris vettese | last post by:
I've been having trouble with this for a long time. I have a form that has many subforms. In the subforms I have unbound text boxes in the footer that sum a field. I want to Display this sum on the main form for each subform and then add them all together. In a book I have it gives the following example: =(Object type!!.Form!) I created an unbound text box on my main form and filled in the information in the example above and get a...
1
2136
by: Argus Rogue | last post by:
Hello All Access Guru's: I was wondering if you could assist me with a little problem that I am having using subform. Is it possible to scroll down a subform to a particular record, click on that record and have it populate the main form?
6
2252
by: MLH | last post by:
I don't always get what I want when I invoke the following Me!MySubFormControl.Refresh from code running in the main form. Am I doing something wrong here? Someone suggested that I open the subform itself (as a separate form) in hidden view anytime I open the main form and attempt my refreshes there. I think that is somewhat redundant and can't be what MicroSoft intended.
9
8079
by: freeskier | last post by:
I am working on a form to edit student field placements. the student is selected from a combo box (cboStudent) which then populates a list box(lstPlacements) with field placements for that student. the fields are on a subform (sfrmEntryPlacements) which populate based on which placement is selected from lstPlacements. sfrmEntryPlacements is on a tab, tabFE, which is on main form frmStudentData. lstPlacements is on tabFE but not on...
2
6947
by: rlamber | last post by:
Hello, I have 2 subforms in a Main form, one links fine, the other doesn't. I am trying to link them both to a "tracking ID" on the main form. The Tracking ID is a text field that is a combination of an auto-number and an Alpha expression. The subform that links fine is a comments form (continuous form with just date field and memo box) and the subform that won't link is a larger, more detailed form where I would like to add more than one...
5
2716
JustJim
by: JustJim | last post by:
I must have Friday-itis! I have a main form which has a sub-form. The sub form is shown as a datasheet, but in design view I have a control on the Form Footer which totals a field on the Detail area. This works fine for the subform when displayed by itself as a single form (including applied filters to simulate being used on the main form) and naturally the total field doesn't appear when the sub-form is shown as a datasheet. On the main...
1
2303
by: Moish | last post by:
I have a form that does not have any bound fields. I want to open a subform on that form to a specific record based on the value of an unbound field on the main form. Obviously the subform is not linked to the main form by master/child fields. I have done some tests. If I add a field to subform whose data source is the field from the main form that I am trying to link the subform with it does display the right information. If I open the...
1
2656
by: greenstein | last post by:
Hello, I really need some help. I have a main form in Access 2000, with a subform, some of the fields in the subform are not saving to the table. When I search the Main form for the information, the subform appears to not have the info. but when I look at the table on the back end, some of the data is there and some is not. I am pretty new to Access and I cannot figure out why the subform is not saving all the info. and why it appears to...
1
2259
by: dekk | last post by:
Hi, I have a main form ("frm_TimeParent") and a subform ("frm_TimeChild"). Issue: How do I refresh the combo box values in the subform once the contract has been selected in the main form? Background: The main form has a combo box ("cbo_Contract") which obtain data from a QUERY ( SELECT ., . FROM tbl_Contract; ) and has a control source ("Contract_id).
4
3515
sueb
by: sueb | last post by:
ADezii helped me with this once, but I must have messed it up somehow and can't figure it out again! All my forms are opened either in Dynaset or Snapshot mode, depending on whether the user has put in the correct password. One of my forms (Patient_IUR_Overview) has a subform (IURs_Abbreviated_subform), and I had the following code in the main form's OnOpen event, which was working great: Private Sub Form_Open(Cancel As Integer) If...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8628
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2754
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.