Refresh a form

P

Paul B.

I have a form where the user opens another form (leaving the original form
open) by clicking on a button. The second form that opens allows the user to
add information to a table. When the user saves the record and closes the
form, I would like to update the original form with the information the user
just saved.

Now I don't know if this is going to cause a problem, but the original form
has a set of records meeting the criteria of a search form, and the user
could have moved to any record in the set. I want the form to remain on the
record selected when the user clicked the button, but this is where I also
want to refresh (if that is the right term) the form.

I have read through the Event Procedures, and perhaps I missed it, but I
could not find an event that would handle this.

Do I have to code this so the form is closed when the user clicks the
button, then re-open it after the user makes the changes? If so, how do I
keep the record on the one the user selected.

Thanks in advance.
 
J

James Goodman

In the form which is opened first (e.g. frm1), add a public sub which is
similar to the following:

Public Sub UpdateRst
Me.Requery
End Sub

In the second form (e.g. frm2) , add the following to the form close event:

Form_frm1.UpdateRst

This should then call the UpdateRst sub from frm1.
 
P

Paul B.

Thanks, now I forgot to say that the form that opens, can be opened by
several different forms. How would the code work since these forms have
different names?

Cheers
 
F

Fred Wilson

The way that I have handled this same issue in the past is like so...
In frm1 on click event
docmd.openform "frm2"
frm2.tag="frm1" 'or some way to designate it as being open from form1


As james pointed out use the public sub on frm1 BUT on frm2 check its
tag first
if frm2.tag="frm1" then form_frm1.updateRst
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top