Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Me.Refresh?

Status
Not open for further replies.

LittleMan22

Technical User
Jun 24, 2001
46
CA
Here's what I'm trying to do:

I have a main form which hold's our client's info which contains a bunch of pages (tabs) one of which contains the client's policies (this is actually linked via a subform called frmpolicies). On this main form I can access a pop-up that contains various fields where the user can enter a new policy for the client. This pop-up form has a command button (to exit) and the user is given the option of storing the policy or not...if they chose to store the policy I have code written that will update the client's data under the main table...however, it will not update the underlying form where the policies are stored (maybe because it's a subform?). So the table is being updated, but not the form. I can exit the main form, come back in, and the form will be updated, however, I want the form to be updated as soon as the policy is entered...(i.e. I want it to appear alongside the other client's policies)

How can I get it so that:

forms!frmClients!subformPolicies is updated when the control for this needs to be written into a pop-up form called frmchangepolicy?

Ryan.
 
Ryan,

Something.Requery should do it.

I got a little lost as to what was where. You can run Me.Requery but that will take you back to the first record in your form.

You can dotRequery individual controls without losing your place. EG: If the policies are in the subform, try Me.Subformname.Requery.


HTH John

Use what you have,
Learn what you can,
Create what you need.
 
Hey John,

Me.subformPolicies.Requery doesn't work...neither does Me.Forms!frmClients!SubformPolicies.Requery...in both instances I get the error message: method or data member not found...

I'm trying to write this code into the 'on-exit' command button of a pop-up form called frmpolicychange. What I want it to do is update the subformpolicies located under a tab on the main form (frmclients). Since this is a subform you can tab (using arrow keys) between all of the existing clients policies which are stored in the database. Ideally, I want code to be written which will update this list of policies to include the one that was just added and upon exiting the pop-up I want the setfocus to go to this new policy...any ideas?

Thanks again,
Ryan.
 
Ryan,

If the code is on the Exit of a popup form then "Me" would be referring to the pop-up form.

Try
Code:
 Form_frmClients.SubformPolicies.Requery

and
Code:
 Form_frmClients.SubformPolicies.Setfocus

I don't use a lot of subforms (I like the flash of popups) so I'm not sure where the focus will end up, but let me know and we'll figure it out.


HTH John

Use what you have,
Learn what you can,
Create what you need.
 
John,

I tried your code but for some reason it closes the main form in the background (frmclients) while the pop-up remains open.

Any ideas how to get around this, or why this is happening? I took out the 'setfocus' control thinking that this could have something to do with the issue, but the problem persisted...
 
Ryan

Would you copy and paste your code here?

And tell me, is the code on the pop-up form's Close event or on the command button's click event?



John

Use what you have,
Learn what you can,
Create what you need.
 
The code is on the Command button (which is on the pop-up form) that allows the user to exit the pop-up form:

Private Sub Command9_Click()
Form_frmClients.subFormPolicies.Requery
Form_frmClients.subFormPolicies.SetFocus
DoCmd.Close
End Sub

Thanks again,
Ryan.
 
OK...I tried putting that same code the exit event procedure of the form and it works...the problem is though that when I requery it takes me back to the beginning of my records...is there a way to 'bookmark' the current client so that the reqeury will simply refresh his/her records and keep me there?

Ryan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top