Refreshing Query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that allows input of orders and on that form a subform showing
the table where the orders are placed. The idea being that one can see
previous orders made etc. The problem I have is that unless I close the form
and reopen it, it doesn't show the last entry made (only if an entry is
modified does it show immediately). Can anyone (with loads of patience!) help
this newbie (it's driving me mad!)???

Thanks
 
I have a form that allows input of orders and on that form a subform showing
the table where the orders are placed. The idea being that one can see
previous orders made etc. The problem I have is that unless I close the form
and reopen it, it doesn't show the last entry made (only if an entry is
modified does it show immediately). Can anyone (with loads of patience!) help
this newbie (it's driving me mad!)???

Thanks

To do it manually, add a button to your form - we usually call it
"Refresh". In the VBA code behind the button, add a line:

Me.Requery

Requery reloads the form from the database, including recently added
records.

Ironically, there is also a Me.Refresh method, which only refreshes
*existing* records, not new ones. But although we use the Requery
method in the code, we call the button Refresh because users seem to
understand it better.

If you want it to happen automatically, then in the main form's After
Insert event, add a line of code:

Me.[MySubformControlName].Form.Requery

using the name of the control that contains your subform.
 
Thanks Armen. Yes I've tried that and still can't get it to update - it only
does so when I go from the 'run' status to design and back again. I put the
line of code in the addrecord button that I have on the main form - is this
maybe the problem?

Armen Stein said:
I have a form that allows input of orders and on that form a subform showing
the table where the orders are placed. The idea being that one can see
previous orders made etc. The problem I have is that unless I close the form
and reopen it, it doesn't show the last entry made (only if an entry is
modified does it show immediately). Can anyone (with loads of patience!) help
this newbie (it's driving me mad!)???

Thanks

To do it manually, add a button to your form - we usually call it
"Refresh". In the VBA code behind the button, add a line:

Me.Requery

Requery reloads the form from the database, including recently added
records.

Ironically, there is also a Me.Refresh method, which only refreshes
*existing* records, not new ones. But although we use the Requery
method in the code, we call the button Refresh because users seem to
understand it better.

If you want it to happen automatically, then in the main form's After
Insert event, add a line of code:

Me.[MySubformControlName].Form.Requery

using the name of the control that contains your subform.
 
Do you mean the AddRecord that sets up the new record for the user to
complete? If so, a Requery there is too early - the record is not
actually added yet. I would put it in the After Insert event of the
main form as I suggested.

Thanks Armen. Yes I've tried that and still can't get it to update - it only
does so when I go from the 'run' status to design and back again. I put the
line of code in the addrecord button that I have on the main form - is this
maybe the problem?
Armen Stein
Microsoft Access MVP
www.JStreetTech.com
 
Yes, that worked lovely - Thanks Armen. I was putting it at the end of the
procedure of the addrecord, thinking that would have caught it. Thanks for
your time mate.

Martin

Armen Stein said:
Do you mean the AddRecord that sets up the new record for the user to
complete? If so, a Requery there is too early - the record is not
actually added yet. I would put it in the After Insert event of the
main form as I suggested.

Thanks Armen. Yes I've tried that and still can't get it to update - it only
does so when I go from the 'run' status to design and back again. I put the
line of code in the addrecord button that I have on the main form - is this
maybe the problem?
Armen Stein
Microsoft Access MVP
www.JStreetTech.com
 

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

Back
Top