Issue with Requery

PNGBill

Win10 Office Pro 2016
Local time
Today, 22:45
Joined
Jul 15, 2008
Messages
2,271
Hi forum, Access 2000

I have a main form with command buttons that provide alternative views of a continuous subform which holds all the records.

In one view we are able to click a command button on each record to go to another form and perform an action on the record.
This example is to Approve an application.

When the task is complete, the Close button on the activity form gets you back to the original main form and then you can click on one of the view buttons to see an updated dataset.
No problems so far.

I thought I would be smart and use a Public Sub so when we perform an activity on the action form it will automatically take you back to the main form and your display will be the option you would have selected to show the updated data.

This doesn't work.

It turns out that while you can do the action and the code has run it's course because a msgbox tells you so, the actual table hasn't been updated.
Hence the Requery is working but makes no diff as the data hasn't been changed.
This only happens when the action form is closed ie, you click the close button and return to the main form.

Is this normal??
Is the table not updated because the form has it open??

Should I include a close for the form in the code on the activity button? and if so, how and where in the code?

trust the above isn't confusing.

Three forms in question. Mainform with continuous subform and the Action form that we go to to do an activity.
 
I think I have resolved this.

Added DoCmd.Close just before the code calling the public function.

extract of code.

Code:
  DoCmd.Close
            stDocName = "FrmLoanApplicationsMain"
            DoCmd.OpenForm stDocName
            Form_FrmLoanApplicationsMain.ApprovedApplications

I should have tried this but thought if the form was closed, wouldn't all code stop?:confused:

it works so I guess that is all that counts:)
 
In the open event of FrmLoanApplicationsMain you could use Docmd.Close "form name".
 
Thanks Poppa Smurf, So you can close the form as you leave or as you enter another form.
Good to know.:)
 
Yes, I open the form that I want then close the form that I came from.
 

Users who are viewing this thread

Back
Top Bottom