+ Reply to Thread
Results 1 to 7 of 7

How to overcome "Compile Error – Ambigious name detected – Run When"

  1. #1
    Registered User
    Join Date
    05-07-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2003/2010
    Posts
    7

    How to overcome "Compile Error – Ambigious name detected – Run When"

    I'm working on a project to update production notes in a manufacturing schedule. I've written a macro called "Open_SFCDB" to pull in the data to the manufacturing schedule and I need to execute the macro in the file automaticaly every 15 minutes, but only while the user has the manufacturing schedule open.

    I've done this by schedule the macro once only in the open event & storing the run time in a public variable. The macro then update the run time for the next interval and reschedule itself. The beforeclose event of the workbook then cancels the scheduled run using the final parameter of Ontime – this works fine on it’s own.

    However my problem now is that I already have some existing vba in the file to close the file automatically after a period on inactivity – which also works fine on it’s own.
    But when I’m trying to blend both requirements into the open event I’m getting the following error “Compile Error – Ambigious name detected – Run When”

    I'm pretty new to VBA so any assistance in helping me combine the codes would be much appreciated.
    See 2 sets of Code I’m trying to combine below

    Existing Code 1:
    Please Login or Register  to view this content.
    New Code 2:
    Please Login or Register  to view this content.
    Normal module

    Please Login or Register  to view this content.

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: How to overcome "Compile Error – Ambigious name detected – Run When"

    do you have another public variable called runwhen?
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    05-07-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2003/2010
    Posts
    7

    Re: How to overcome "Compile Error – Ambigious name detected – Run When"

    Hi JosephP,

    This is the code I currently have for RunWhen.

    Public RunWhen As Double
    Please Login or Register  to view this content.

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: How to overcome "Compile Error – Ambigious name detected – Run When"

    you can't have two public variables with the same name. if you're trying to run separate routines on separate schedules rename one of the variables and update the codes that use it

  5. #5
    Registered User
    Join Date
    05-07-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2003/2010
    Posts
    7

    Re: How to overcome "Compile Error – Ambigious name detected – Run When"

    Hi JP,
    Thanks for replying. I just want to double check my understanding on this is correct - I could allow the 1st routine to run on "run_when" and then change the 2nd routine to run on "run_when2" and adjust the various codes accordingly, then this will sort it out.
    God is good, but never dance in a small boat.

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: How to overcome "Compile Error – Ambigious name detected – Run When"

    yes that's correct :-)

  7. #7
    Registered User
    Join Date
    05-07-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2003/2010
    Posts
    7

    Re: How to overcome "Compile Error – Ambigious name detected – Run When"

    Thanks again JP
    I really appreciate your help

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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