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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refreshing a form - HELP!!!

Status
Not open for further replies.

vfisher

Programmer
Apr 15, 2002
40
US
I am using Access 97. I have a form with a subform. There is a field in the subform that is summed in the footer of the subform. When the data in the subform is altered, I am validating it from the main form via a save button. The problem is that the sum in the footer of the subform may or may not be updated when the save button is clicked.

To be sure, I added a refresh of the form in the save code. This seems to work when I walk thru the code, but when I don't have the code trapped, it appears the refresh may not actually be complete when the code for the validation is executed.

Is there some way to wait for the refresh to be complete or include some kind of delay before the validation code runs.

Thanks in advance. Any help is greatly appreciated.
 
I think you may need to do a REQUERY of the sub-form's data in order for the refresh to recalculate with the new numbers.

Forms!{main-form}.{subform-control-name}.FORM.REQUERY

should do it for you.

Jim How many of you believe in telekinesis? Raise my hand...
Another free Access forum:
More Access stuff at
 
Thanks for the advice; however, I still have the same problem. I do the requery at the top of the code behind the save button, then do all the validation. When the validation takes place, the amount is not updated, but after the validation it is.

Is there some way to wait for the requery to be completed??

 
Well, I used Recalc to get the calculated field updated. However, recalc resets the tab order to the first row. I tried to set the Cycle = 1 (Current Record) and the focus on the next field, but it always goes back to the first on the first row of the subform.

Is there some way to keep is on the current row?

Thanks
 
It sounds like you're ADDING new rows to the recordsource and you want to do a "save this change, recalculate the total, and then put me back were I was with the (new?) record", no??

The requery gets a fresh new recordsourse. So basically, as soon as that happens, you lose your positioning.

I'm not sure where you want to reposition yourself (parent record or child record), but you can look at the BOOKMARK property to see how to set a bookmark AFTER you make the new insert but BEFORE you do the requery, and then return to the bookmarked record.

Are we on the same page?...

Jim
How many of you believe in telekinesis? Raise my hand...
Another free Access forum:
More Access stuff at
 
Jim,

That's exactly what I want to do. I have several fields in the record, but when the amount field is entered, the calculated field needs to be updated. when I did the recalc and set focus on the next field, it was the field in the first row.

I'll try using bookmark. Thanks for the advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top