Macros executing twice

I have several macro's defined in a Access DB. An example follows:

OpenQuery    'Query by I-C'
Maximize
GoToRecord    'First'
Runcommand    SortAscending

The query has two fields (out of five fields) with criteria as follows:

Like "*" & [Input Item] & "*"

for searching anywhere within a field for a given value.

The macros work well for about half a day; then suddenly the macros all execute twice every time I invoke them, either directly or via a custom button.
cbeanAsked:
Who is Participating?
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.

cbeanAuthor Commented:
I'm not sure how to rate a question as to easy .. hard, etc
0
lmerrellCommented:
The main reason you are getting a double prompt is because of the sort in the macro.  The first time the macro runs the query you get prompted.  When you sort the query and save it sorted you will get a prompt the next time the macro is run.  This is because a saved sort on a query is in itself a query.  The best way to avoid this situation is to include all sorting in the design mode of the query.

lmerrell
0
lmerrellCommented:
Let me know if you need any clarification on any of this.

lmerrell
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

cbeanAuthor Commented:
Thanks for your quick answer, Imerrell.

I removed the 'SelectAllRecords'
and the 'SortAscending' commands from the macro, and the same problem occurs.
Also, when I go to the Query tab and select the query directly, I get
the same results (double prompt).
0
lmerrellCommented:
Okay, next step.  ;-)  Open your query in design mode and right-click on the query grid and select Properties...  Look at the Query Property Order By.  If there is a value there, remove it and resave your query.  This Order By is what causes the query to run again.  If there is not a value there let me know.

lmerrell
0
lmerrellCommented:
cbean,

Did that take care of your problem?  If so, you can either "Accept comment as answer" or let me know and I'll post an answer for you to grade.

lmerrell
0
cbeanAuthor Commented:
That was the problem, but it took me some time to find out why and how the 'Query Order By' keeps getting turned back on.  It appears that if you click 'Yes' to saving the DB upon exiting, it is not saving additions or changes to the DB, but saving changes like ordering, column width, etc.
Is that basically right?
0
lmerrellCommented:
That's right, cbean.  There is a way around this though.  If you create a Datasheet view form based on the query you can sort and filter the form all you want and it doesn't have to rerun the query (it works with the retrieved recordset) therefore you will not get double prompts.  The Datasheet view form looks just like an executed query.

Let me know if you want to do this and I'll be happy to help out.  I'm going to go ahead and post this as an answer but you can still post any further questions here concerning the form.

Happy Holidays,

lmerrell
0

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
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.