+ Reply to Thread
Results 1 to 15 of 15

can a vba be written to start another macro if a triggering event has happened?

  1. #1
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    can a vba be written to start another macro if a triggering event has happened?

    I'm using the following macro to close out error messages which occasionally pop up during data queries:

    Please Login or Register  to view this content.
    A typical error might say "[expression.error The column of "Date" of the table wasn't found.]. Closing this error message appears to work... because I see the circling icons in the data queries indicating that the query is stuck. If I manually close out the error message, the tables will not refresh even though it looks like they are (error closes out. circles appear again briefly. looks like all is well. but its not. all of the tables have not been refreshed). So.. is there a method where the macro determines if it has been invoked... and if so, then click the "refresh all"? I know that an alternative solution is to set up another macro to "refresh all" every x minutes or so but this is not practical for my purposes. Thanks.

  2. #2
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: can a vba be written to start another macro if a triggering event has happened?

    I think you are approaching this sideways.

    You are not closing errors, you are preventing them from displaying. This doesnt mean they dont happen, it just means you never see the dialog. The problem with this is the same as if the dialog popped up behind Excel and you never noticed...whatever failed still failed and has not been addressed yet.

    You see the indicator circling because the action is perpetually running, failed and waiting for you to gracefully exit the process via the dialog you never see as you disabled displaying them.

    More than likely, you simply need to address the cause of the issue, not the symptom. If manually closing the error doesnt resolve the problem, VBA "closing" it wouldnt be any different. The fact of the matter is the error is likely valid and you need to correct the cause to have things function properly.
    Ways to get help: Post clear questions, explain your overall goal, supply as much background as possible, respond to questions asked of you by those trying to help and post sample(s) files.

    "I am here to help, not do it for people" -Me

  3. #3
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    Re: can a vba be written to start another macro if a triggering event has happened?

    Yes I do understand your message and that was my initial approach. But I need help in determining the source of these errors, so on July 31 I posted a question here describing one of the errors, but no one has responded to that post.

    While waiting for help, I decided to try to discover the solution on my own. The challenge though is that these errors are not specific to an particular query (I have multiple queries). I changed various queries and their settings, but these attempts didn't work.

    As I was going through these procedures though, I noticed that every time I closed out an error message to try to dig in and find a solution, the spinning circles stopped and there were no yellow messages (on the queries themselves) indicating that data hadn't loaded. So I thought all of the tables were updated. I guessed that the errors could have been due to network delays or an internal bug in Excel (overwhelmed with too much work at once) or something similar.

    But.... I was wrong in my assumption. So if anyone knows how to trace a db query error message to its source, or help me force a "refresh" after an error, I'll appreciate some guidance. (forcing a refresh always works... thus the purpose of my post here

    Thanks

  4. #4
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: can a vba be written to start another macro if a triggering event has happened?

    Well I cant speak to your original message but I can say that right now, I have nothing to go on. A sample file, the exact error message, screenshots, etc would go a long way to getting help.

    As for the spinning circle, think of it like this: You walk up to someone and start to speak. They cut you off and ask you to hold on...so you just stand there awkwardly silent waiting...

    Thats what the spinning circle is showing, nothing else. Your error message is still occurring, its causing the program to stop what its doing and waiting until it can continue to "speak". Since you have hidden the dialog to allow it to end, it never does and just spins forever.

    As you get the error manually, its almost 100% not a VBA related issue but an issue in the table/query. We would need more detail, and most helpful of all would be a sample so we can see it for ourselves.

    You can manually refresh tables, 1 by 1, until the error occurs. The process of elimination will help you trouble shoot which table(s) are problematic. Once you figure out which table you then use the error message to help trace the cause in that table (your OP mentions a column).

  5. #5
    Registered User
    Join Date
    08-07-2018
    Location
    Tilburg
    MS-Off Ver
    2016
    Posts
    32

    Re: can a vba be written to start another macro if a triggering event has happened?

    you can easily have a vba use another macro incase an error occurs.
    after an error you can use something like this:

    Please Login or Register  to view this content.
    what I always do is draw a workflow so I can see what it has to do.
    In your case IF an ERROR occurs then do THIS, but IF NO ERROR occurs then proceed with the current PROCESS
    Last edited by Teddi; 08-07-2018 at 08:53 AM.

  6. #6
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    Re: can a vba be written to start another macro if a triggering event has happened?

    Thanks Zero. Here's my original post which shows one error:

    orig post

    Here's a screenshot of another error.
    exampleerror2.png
    Could a problem possibly be that I have some queries loading to rows below another query?

    Note that most of the time if I see an error, three of the data queries are "spinning," not just one. When I close out the error message to begin diagnosing the problem, all of the circles stop spinning, so I don't know which one was causing the issue. I could quickly recreate the queries in separate notebooks to see where errors occur. Does that sound like a reasonable starting point? And/or I could paste the actual query here (as found in the Edit console) if that helps.

    All of the queries are web based. I use the Excel feature to paste in a URL, then I go to Edit, and will often remove or save columns using the edit GUI.

  7. #7
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    Re: can a vba be written to start another macro if a triggering event has happened?

    Thanks Teddi. So is this the correct syntax? (I'm stupid with VBA!)

    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: can a vba be written to start another macro if a triggering event has happened?

    Quote Originally Posted by jrtaylor View Post
    Here's a screenshot of another error.
    My first instinct from your screen shot is to say the error is right. In column H you have "date" not "Date" (IE: the query is looking for "Date" but the column is actually "date", so it cant find it). They are not the same thing. I am basically 100% these are not VBA issues as they happen manually and via your screenshot you have shown context which proves this.

  9. #9
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    Re: can a vba be written to start another macro if a triggering event has happened?

    Hmm..... in the workbook there are three dynamic tables with a date (or Date) column. I do not manually label any of the column headings in these tables.

    Two of the dynamic tables with dates have headings which are pulled from the web query itself which Excel is creating via the "get data from web" function.
    The third table (which begins at column H) is populated from a MySql database. I checked the database itself to see how that column is labeled and it has a small "d" date (and again, I do not manually label the column. The heading is pulled from the db).

    I think at this point I'm going to create three independent workbooks, each with a single web query and see what happens. Thanks for sticking with me on this!

  10. #10
    Registered User
    Join Date
    08-07-2018
    Location
    Tilburg
    MS-Off Ver
    2016
    Posts
    32

    Re: can a vba be written to start another macro if a triggering event has happened?

    If that is what you need then that is correct.
    keep in mind to change FileName and Macroname into the file name and macro you want to run when an error occurs.

    Quote Originally Posted by jrtaylor View Post
    Thanks Teddi. So is this the correct syntax? (I'm stupid with VBA!)

    Please Login or Register  to view this content.

  11. #11
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: can a vba be written to start another macro if a triggering event has happened?

    Quote Originally Posted by jrtaylor View Post
    The third table (which begins at column H) is populated from a MySql database. I checked the database itself to see how that column is labeled and it has a small "d" date (and again, I do not manually label the column. The heading is pulled from the db).
    Yes, but who wrote the query Excel uses to pull the data?

    The error message indicates the query is clearly looking for 'Date' not 'date', so I would bet the query is the issue here. However I cant see your query to tell.

    Everything has to be in exactly the same terms. Its fine if the heading in the SQL is actually 'date', as long as the query in Excel and any code that reference it are as well.

  12. #12
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    Re: can a vba be written to start another macro if a triggering event has happened?

    Hi Zero, I created the table using Excel's "get data from MySql" feature. I begin by entering the db's credentials. Excel makes the connection and shows me the tables in the db to choose from. I click the one I want and that creates the basic query. I click "edit" on the query which opens the Power Query Editor. Since I only want to keep the last x rows of the data (which goes back maybe 5 years) I click on the "Keep Rows" button and keep the bottom 30 rows. Then I "Load to" cell H1 and the table populates on the worksheet. (And on the other tables which obtain data from the web, I go through the same process, except for the first step. Instead of using the "get data from MySql" feature, I use "get data from web")

  13. #13
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: can a vba be written to start another macro if a triggering event has happened?

    You can see the query string being used by going to Data | Connections and selecting the connection, then properties and there should be a query filed. Post the query if you can for the Table that has the 'date' column with lower case.

    In Excel 2016 I think you can do Data | Show Queries but I haven't used it recently so I am not sure where it displays the query string.

  14. #14
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    Re: can a vba be written to start another macro if a triggering event has happened?

    This is the actual query, (I obfuscated db names but all else remains same).

    I can send a screenshot of the actual mysql schema if that helps.


    Please Login or Register  to view this content.
    And here's a screenshot of the powerquery editor

    powerqueryeditor.png

    Thank you

  15. #15
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: can a vba be written to start another macro if a triggering event has happened?

    Quote Originally Posted by jrtaylor View Post
    Please Login or Register  to view this content.
    And theres your problem (highlighted in red text quoted above, may need to scroll to see it), query is set to look for "Data", not "data". Your tables headers lower case, the query knows "Data" <> "data". Either update your query or change the headers. Need everything in like terms.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. What happened to Start?
    By Benny2.0 in forum Office 365
    Replies: 5
    Last Post: 06-23-2018, 10:11 AM
  2. Triggering an event in a csv file
    By mediaeval in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-06-2017, 12:01 PM
  3. Need Help with Event Triggering when value changes
    By calvinloo in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-12-2015, 03:54 AM
  4. EVENT triggering?
    By EXLent in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 08-19-2014, 07:16 AM
  5. [SOLVED] change event not triggering macro
    By cmccabe in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-27-2014, 01:15 PM
  6. Event triggering
    By Sarimdesert in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-22-2014, 03:26 AM
  7. VBA Event triggering
    By teachMeExcel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-04-2012, 02:12 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1