• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 357
  • Last Modified:

Refreshing records on a continuous form

I'm just Mr. Question today :-)

I have a continuous form showing a list of call list records (currently 13 of them). I have a button on the header of this form that opens another form which allows me to enter a new record, runs an append query to add it to the records and closes the 'add new record' form, so the focus is back with the original call list form.  However, the number of records has not changed.  If I add a 'me.refresh' after the sub form has closed, I still don't get the new record.  If I go into design mode and back to preview mode, I still don't get the new record. If I shut the form and re-open it, THEN I get the new record.  The record source for the form is a simple query that has two tables in it: the one I'm updating (call list) and a list of Caller's names (caller names) that's linked by Caller ID.  The query is not just specific to the form, it exists in the 'query' windows as well.  How come the 'refresh' doesn't work and I only see the new record if I close and re-open the form?
0
carled
Asked:
carled
  • 11
  • 6
  • 3
  • +2
1 Solution
 
dsegardCommented:
For that, you need to use the requery method.

DS
0
 
brewdogCommented:
dsegard is right on (though an explanation might be helpful :)  )

The refresh method will update all changes to existing data (meaning no additions or deletions will be reflected). The requery method reflects *all* changes to data: edits, adds, deletes. The requery takes a little longer generally (there is no specified set of records in memory to update like with the refresh) and, on a bound form, will always move you back to the first record in the table/query. That is why the requery is sometimes used with the bookmark property, too; then you can requery and return the user to the record they were just viewing.
0
 
carledAuthor Commented:
The requery works.  I'm irritated because I'd tried that and it didn't seem to work so I'd disregarded it, but I had the code in the wrong place!

However...
I don't want the user to have to click on the 'requery' button to see the latest records.  I've tried putting the code in just after the subform call, but using the debugger, the system steps through the 'requery' before the subform appears on screen!  I've tried putting in a further subprocedure and calling the subform from that, then performing the requery but as soon as the subform call is done it steps right through the requery and THEN shows the subform on screen.  I seem to need some kind of 'wait' once the subform has been entered.  Alternatively, is there an 'event' that corresponds to the end of processing on a button click?  I tried 'got focus' but that did nothing.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
carledAuthor Commented:
The requery works.  I'm irritated because I'd tried that and it didn't seem to work so I'd disregarded it, but I had the code in the wrong place!

However...
I don't want the user to have to click on the 'requery' button to see the latest records.  I've tried putting the code in just after the subform call, but using the debugger, the system steps through the 'requery' before the subform appears on screen!  I've tried putting in a further subprocedure and calling the subform from that, then performing the requery but as soon as the subform call is done it steps right through the requery and THEN shows the subform on screen.  I seem to need some kind of 'wait' once the subform has been entered.  Alternatively, is there an 'event' that corresponds to the end of processing on a button click?  I tried 'got focus' but that did nothing.
0
 
carledAuthor Commented:
The requery works.  I'm irritated because I'd tried that and it didn't seem to work so I'd disregarded it, but I had the code in the wrong place!

However...
I don't want the user to have to click on the 'requery' button to see the latest records.  I've tried putting the code in just after the subform call, but using the debugger, the system steps through the 'requery' before the subform appears on screen!  I've tried putting in a further subprocedure and calling the subform from that, then performing the requery but as soon as the subform call is done it steps right through the requery and THEN shows the subform on screen.  I seem to need some kind of 'wait' once the subform has been entered.  Alternatively, is there an 'event' that corresponds to the end of processing on a button click?  I tried 'got focus' but that did nothing.
0
 
carledAuthor Commented:
The requery works.  I'm irritated because I'd tried that and it didn't seem to work so I'd disregarded it, but I had the code in the wrong place!

However...
I don't want the user to have to click on the 'requery' button to see the latest records.  I've tried putting the code in just after the subform call, but using the debugger, the system steps through the 'requery' before the subform appears on screen!  I've tried putting in a further subprocedure and calling the subform from that, then performing the requery but as soon as the subform call is done it steps right through the requery and THEN shows the subform on screen.  I seem to need some kind of 'wait' once the subform has been entered.  Alternatively, is there an 'event' that corresponds to the end of processing on a button click?  I tried 'got focus' but that did nothing.
0
 
carledAuthor Commented:
Sorry about the multiple entries... got carried away with the 'retry' button there!

Managed to work around the problem by doing the 'requery' from the subform so by the time I get back to the main form it's all there.

More easy points for DS!
0
 
brewdogCommented:
so the "other form" you're opening is a subform on the main form? I was thinking it would be a popup form. If that were the case, you could just do:

docmd.openform "YourPopupForm",,,, acdialog
me.requery

with the acdialog argument, the next line of code won't run until the dialog box closes . . . which in this case would be after the user has entered the new record.
0
 
dsegardCommented:
Yes, it's rather easy today ! It looks like at office : some holidays...

DS
0
 
brewdogCommented:
step right up! submit your answer and claim your points, dsegard!
0
 
dsegardCommented:
You provided a complete explanation and spent a lot of time instead showing the right way in a few words like I do sometimes - and often when I make some training for technical support team of my company.

I was snoring in the lounge...

DS
0
 
carledAuthor Commented:
Sorry Brewdog, dodgy terminology.  It is, in fact, a pop-up form, not a subform.  I tried the 'acDialog' - it didn't seem to work.  (Maybe I need to set the form to 'popup' or something?)
0
 
TrygveCommented:
For your information: In Access2000, the refresh method is supposed to also include requerying the data.

You could let the OnClose event of the "other" form requery your main form?
0
 
carledAuthor Commented:
True, but as the 'update' button on the pop-up form just runs the query, closes the form, then requeries... it wouldn't make a lot of difference!
0
 
carledAuthor Commented:
You want these points or what, DS ?
0
 
dsegardCommented:
Brewdog has written clear explanation and gave you complete support - not only "use requery...".

It would be unfair to take the answer as mine. Hope you understand my position.

DS
0
 
carledAuthor Commented:
Does anyone want these points or shall I delete the question? (Can I delete the question?)

Vote guys - anyone who's interested!
0
 
gigo30Commented:
Use the requery method. I'll take the points. :)

0
 
dsegardCommented:
You won't be exhausted at the end of the day...
0
 
carledAuthor Commented:
No, come on guys, play the game!

DS, the points are yours - get your answer in, please!
0
 
dsegardCommented:
Ok Carled.

DS
0
 
carledAuthor Commented:
Thankyou
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 11
  • 6
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now