?
Solved

Update/Refresh a subforms data

Posted on 2003-03-20
6
Medium Priority
?
1,305 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
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
A Case Study of using the Windows API to provide RS232 communications capability in Access without the use of Active-X controls.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

621 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