?
Solved

Update/Refresh a subforms data

Posted on 2003-03-20
6
Medium Priority
?
1,291 Views
Last Modified: 2012-06-27
I have a form, Form1 with a subform, SubformGAP.  SubformGAP's control is a query whose criteria comes from text boxes on Form1.  SubformGAP is a datasheet form.
Here is what I would like to happen.
When I click a button "Refresh" on Form1, the SubformGAP query is run and the data that appears in the subform is refreshed.
I'm not sure how to make this happen.  I've built a button that runs the query for SubformGAP, but all it does is open the query on top of Form1.  Rather than have the query open, I want the datasheet in the subform to display the new data.

Hope this explination is at least a little bit clear.  Thanks in advance for your help!!
0
Comment
Question by:TrantinasAccess
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 18

Expert Comment

by:1William
ID: 8176432
in the onclick event:
Forms![SubformGAP] .requery
0
 
LVL 3

Expert Comment

by:syntnx
ID: 8176466
Trantinas,

Try this. Place the subform on form 1 and create a button with the onClick set to run the following:

DoCmd.RunCommand acCmdRefresh

I know this works with a subform linked via master/child field (ie: relationship). Give it a try with your query.

Hope this helps

Tim
0
 
LVL 3

Expert Comment

by:syntnx
ID: 8176472
Trantinas,

Try this. Place the subform on form 1 and create a button with the onClick set to run the following:

DoCmd.RunCommand acCmdRefresh

I know this works with a subform linked via master/child field (ie: relationship). Give it a try with your query.

Hope this helps

Tim
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 

Author Comment

by:TrantinasAccess
ID: 8177627
Thanks for the ideas, however...

When I add Forms![SubformGap].requery to the onclick event property of the button on Form1, I get the following error message:  Microsoft Access can't find the macro 'forms!subformGap'
Interesting... so I tried to put an '=' in front of it to identify it as a function.  Still no luck.

The Docmd.RunCommand acCmdRefresh had a similar problem when I built it as a procedure under the OnClick command.  The message received is:  The command or action 'Refresh' isn't available now.

Any other thoughts on either one of these commands?  Perhaps I missinturpreted something.  Thanks for your help!!

0
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 300 total points
ID: 8177964
Forms!Form1!SubformGAP.Form.Requery

Make sure that the name of the subform *control* is SubformGAP - it is often not the same name as the subform (open the main form in design view, click on the subform and check its Name property in the Properties window).
0
 

Author Comment

by:TrantinasAccess
ID: 8182266
Thanks much for your help.

After doing a couple tests it appears that I don't need to add anything to the onclick procedure of the button or form.  For this particular query and subform, all I had to do was add the subform to the main form, and that was it.
The date fields on the main form that are the search criteria for the query seem to do all the work.  Once I enter a new date range and tab out of the End Date field, the subform data is automatically updated.
Thanks for the help!!
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question