form refreshrequery q anthony

Forum home » Delegate support and help forum » Microsoft Access Training and help » Form Refresh/Requery Q for Anthony

Form Refresh/Requery Q for Anthony

resolvedResolved · High Priority · Version 2007

Edited on Wed 22 Feb 2012, 17:06

Timothy has attended:
Access Advanced course

Form Refresh/Requery Q for Anthony

Hi Anthony,
Next little annoying one. Am trying to make a form (Frm1) update it's data when it is re-selected. I open another form (Frm2) and make a change to some data. This data is also displayed in Frm1. When I close Frm2 and click on Frm1 the previous value is displayed in Fmr1 and not the new value I had just entered.

I have attempted to make the Form Requery on Activate but that has not worked, though possibly becuase I wrote the code wrong. Have tried:
Form_Load()
1.Me.Requery
2.Forms!Frm1.Requery

Any thoughts on this one?
Cheers
Tim

RE: Form Refresh/Requery Q for Anthony

Ok so a slight change to this question now.
What I think is going on is that when I update a value in Frm2 I'm actually changing a value that causes an update query to open which changes a value that is shown in Frm1. That is the value I want to appear/update automatically.

Frm1 is based on a parameter query, so causing a requery does update the value. But If I actually edit another value in Frm1 through another ,Frm3, where I am actually editing the table directly through a bound control; Frm1 is updated immediately.

Causing requery has its own problem in that I want to automatically input the parameter value into the query instead of being prompted for it each time. How can I 'get at' the parameter query to do this?

Cheers
Tim

RE: Form Refresh/Requery Q for Anthony

Hi Tim. If it's just a straight parameter query it should be available in the criteria of the query in query designer. If it's buried any deeper it might be macro based or coded, but I doubt it.

Anthony

RE: Form Refresh/Requery Q for Anthony

Hi Anthony, that's simple enough.
The problem presents itseld when requerying the form, as it is based on the parameter query it asks for a value to be entered. I want it to automatically use the value that was entered before to get the form to show the data it was before running requery.
So can't change the underlying parameter query as I still need the initial value request but want the automatic value input when the form requeries.
I suppose it would be easy if the requery method allowed you to input arguments for the parameter query but that is not the case, at least I can't find a way of doin that.
Cheers
Tim

RE: Form Refresh/Requery Q for Anthony

Ah, OK. That sort of thing we would normally do in VBA to capture values, drop them into a variable and use them to influence form contents downstream.

However, consider writing the initial values caputured by the first parameter query (or enter the parameters in text fields) to a temp table (i.e. run an append query) and then use the values on that temp table to drive the results on the subsequent form. It's something of a scenic route but this is how you can capture values in one place and use them to drive results in others.

Anthony

RE: Form Refresh/Requery Q for Anthony

I was thinking that the VBA route would have been the way to go, I did flirt with it for this one but wasn't sure where the vaiable should get put back in.

Anyway, I did get round this in the end though with a slightly different route, using a text box on a form next to the button that opens the parameter query based form. Then when I requery it's all good and I didn't have to change everything else that runs of the query form because the correct value is still there.

Out of interest when you run the append query as a temporary store of data for the form, if you run the append several times you will have a stack of data. I assume you then have to set the forms on load event to go to the last record to get the right result, or just change the criteria in the form query so that latest is selected. Is that intentional as it seems like a chance for more things to go skewif.

Cheers
Tim

RE: Form Refresh/Requery Q for Anthony

My preference would have been for the text box solution as well. As long as it doesn't compromise the form design it's the cleanest solution. The temp table would need definitely need to be managed, with either most recent record usage data, delete queries, or flushing on close.

Anthony

 

Training courses

 

Training information:

See also:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Access tip:

Create calculated fields that work out your age

You can uset eh year function to work out the year from NOW function and then subtract it with your date of birth type field

Age=Year(Now( ))-Year([DoB])

View all Access hints and tips


Server loaded in 0.05 secs.