Requery

I would like an after update to requery a query... the query is titled: qryMemoEmail650

What would that code be?
cansevinAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mbizupCommented:
How is the query being used?

recordsource of the current form:

Me.Requery

Open in new window


recordsource of another form:

Forms!FormName.Requery

Open in new window


Rowsource of a combo or listbox:

Me.cboComboName.Requery

Open in new window


Query open in datasheet view:

Docmd.OpenQuery "qryMemoEmail650"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cansevinAuthor Commented:
Thank you mbiz... the query is being used for a DLookup. The DLookup is part of a button that sends an email. I am having trouble and have to click off the form and them back on for it to work. Or I have to CTRL F9 to update everything. I am hoping if I tell it to requery it will run smoother. So the query just is in the background and then gets refered to in a DLookup. Does that make sense? I don't really need it open... but just want it to updated.
mbizupCommented:
Gotcha.

It sounds like the current record on the form is not actually saved at the time you click the button, so the DLookup is returning old data.   Does that seem like the issue?

Try adding this line immediately before the DLookup:

Me.Refresh

Open in new window

cansevinAuthor Commented:
Ok... Thanks I'll try that. Might be the solution. It is not that it is pulling up old data, it is actually pulling up no data at all. When I try to open the query by itself it is blank.

Really appreciate your help on this!
PatHartmanCommented:
Me.Refresh is intended to update the records of the form's ControlSource.  As a side effect it saves the current record.  I don't like relying on side effects.  I prefer to be explicit so I would use:

DoCmd.RunCommand acCmdSaveRecord

That way, the reader knows for sure what is happening.  A novice might not know the side effects of Me.Refresh and Me.Requery.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.