• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

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.
0
cbean
Asked:
cbean
  • 5
  • 3
1 Solution
 
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now