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

requery not working

Status
Not open for further replies.

rry2k

Programmer
Jun 28, 2001
678
US
I have an app with a form and subform. The form displays records in datasheet view and when a button is clicked I bring up a different form to add a new record. The problem is: when the user clicks close and goes back to form1 the new record isn't there until I close the form and go back in. I've tried refresh and requery on various events but no luck.

Thanks for the help..Russ
 
I had the same problem.
The solution is to insert following code in the "on close" event of your Form2

Private Sub Form_Close()
Dim frmCurrentForm As Form
Set frmCurrentForm = Forms("Form2")
frmCurrentForm.Refresh
End Sub
 
If form1 is the view,datasheet form and form2 is the add form, would I do the refresh on form2? That doesn't seem to be quite right because the view form(form1) is the one that isn't refreshing with the new record.

Thanks..Russ
 
yes ! you are right, sorry ! you need to refresh form1.
Set frmCurrentForm = Forms("Form1")

Marc
 
Thanks for the try Marc but that didn't work for some reason.
 
Russ, it works !!!
for years i cheated by doing "go to previous record, go to next record" until a colleague gave me this solution and it works. I have a form1 (order/Invoice) with a subform1 (list of articles ordered), I have a button that open a new form2 that display the articles, I choose an article and enter a quatity, then press a button that create a new line in my order subform1. when I close this form2, the code I gave you refresh the form1 (you have to give the name of the form1 not the subform1).If your .mdb file is not too big, you could send it to me so that I could make it work OK?
 
Your code worked. Somehow something was tangled up and when I closed the db and came back in everything was cool.

Thanks alot..Russ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top