<p>I have the following code:</p>

<pre><code>Dim obj As New Access.Application
obj.OpenCurrentDatabase (CurrentProject.Path &amp; "\Working.mdb")
obj.Run "Routine"
obj.CloseCurrentDatabase
Set obj = Nothing
</code></pre>

<p>The problem I'm experimenting is a pop-up that tells me Access can't set the focus on the other database. As you can see from the code, I want to run a Subroutine in another mdb. Any other way to achieve this will be appreciated.</p>

<p>I'm working with MS Access 2003.</p>

<p>This is an intermittent error. As this is production code that will be run only once a month, it's extremely difficult to reproduce, and I can't give you the exact text and number at this time. It is the second month this happened.</p>

<p>I suspect this may occur when someone is working with this or the other database.</p>

<p>The dataflow is to update all 'projects' once a month in one database and then make this information available in the other database.</p>

<p>Maybe, it's because of the first line in the 'Routines' code: 
   If vbNo = MsgBox("Do you want to update?", vbYesNo, "Update") Then 
       Exit Function 
   End If</p>

<p>I'll make another subroutine without the MsgBox.</p>

<p>I've been able to reproduce this behaviour. It happens when the focus has to shift to the called database, but the user sets the focus ([ALT]+[TAB]) on the first database. The 'solution' was to educate the user.</p>

<hr>

<p>This is an intermittent error. As this is production code that will be run only once a month, it's extremely difficult to reproduce, and I can't give you the exact text and number at this time. It is the second month this happened.</p>

<p>I suspect this may occur when someone is working with this or the other database.</p>

<p>The dataflow is to update all 'projects' once a month in one database and then make this information available in the other database.</p>

<p>Maybe, it's because of the first line in the 'Routines' code:
    If vbNo = MsgBox("Do you want to update?", vbYesNo, "Update") Then
        Exit Function
    End If</p>

<p>I'll make another subroutine without the MsgBox.</p>

<hr>

<p>I've tried this in our development database and it works. This doesn't mean anything as the other code also workes fine in development.</p>

[{'answer_id': 70413, 'author': 'Steve Morgan', 'author_id': 5806, 'author_profile': 'https://Stackoverflow.com/users/5806', 'pm_score': 2, 'selected': False, 'text': '<p>I think the nearest in the .NET Framework is </p>\n\n<pre>\nstring.Split()\n</pre>\n'}, {'answer_id': 70425, 'author': 'Tim Jarvis', 'author_id': 10387, 'author_profile': 'https://Stackoverflow.com/users/10387', 'pm_score': 4, 'selected': False, 'text': "<p>The split method of a string is what you need. In fact the tokenizer class in Java is deprecated in favor of Java's string split method.</p>\n"}, {'answer_id': 70436, 'author': 'Davy Landman', 'author_id': 11098, 'author_profile': 'https://Stackoverflow.com/users/11098', 'pm_score': 8, 'selected': True, 'text': '<p>You could use <a href="http://msdn.microsoft.com/en-us/library/system.string.split.aspx" rel="noreferrer" title="String.Split method msdn reference">String.Split method</a>.</p>\n\n<pre><code>class ExampleClass\n{\n    public ExampleClass()\n    {\n        string exampleString = "there is a cat";\n        // Split string on spaces. This will separate all the words in a string\n        string[] words = exampleString.Split(\' \');\n        foreach (string word in words)\n        {\n            Console.WriteLine(word);\n            // there\n            // is\n            // a\n            // cat\n        }\n    }\n}\n</code></pre>\n\n<p>For more information see <a href="http://www.dotnetperls.com/split" rel="noreferrer" title="C# Split String Examples by Sam Allen">Sam Allen\'s article about splitting strings in c#</a> (Performance, Regex)</p>\n'}, {'answer_id': 70449, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>For complex splitting you could use a regex creating a match collection.</p>\n'}, {'answer_id': 70463, 'author': 'Paul Shannon', 'author_id': 11503, 'author_profile': 'https://Stackoverflow.com/users/11503', 'pm_score': -1, 'selected': False, 'text': '<p>If you are using C# 3.5 you could write an extension method to System.String that does the splitting you need. You then can then use syntax:</p>\n\n<pre><code>string.SplitByMyTokens();\n</code></pre>\n\n<p>More info and a useful example from MS here <a href="http://msdn.microsoft.com/en-us/library/bb383977.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb383977.aspx</a></p>\n'}, {'answer_id': 1205918, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': '<p>use <code>Regex.Split(string,"#|#");</code></p>\n'}, {'answer_id': 1720739, 'author': 'Musa', 'author_id': 209393, 'author_profile': 'https://Stackoverflow.com/users/209393', 'pm_score': 0, 'selected': False, 'text': '<p>read this, split function has an overload takes an array consist of seperators\n<a href="http://msdn.microsoft.com/en-us/library/system.stringsplitoptions.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.stringsplitoptions.aspx</a></p>\n'}, {'answer_id': 18905125, 'author': 'demongolem', 'author_id': 236247, 'author_profile': 'https://Stackoverflow.com/users/236247', 'pm_score': 5, 'selected': False, 'text': "<p>I just want to highlight the power of C#'s Split method and give a more detailed comparison, particularly from someone who comes from a Java background.</p>\n\n<p>Whereas StringTokenizer in Java only allows a single delimiter, we can actually split on multiple delimiters making regular expressions less necessary (although if one needs regex, use regex by all means!)  Take for example this:</p>\n\n<pre><code>str.Split(new char[] { ' ', '.', '?' })\n</code></pre>\n\n<p>This splits on three different delimiters returning an array of tokens.  We can also remove empty arrays with what would be a second parameter for the above example:</p>\n\n<pre><code>str.Split(new char[] { ' ', '.', '?' }, StringSplitOptions.RemoveEmptyEntries)\n</code></pre>\n\n<p>One thing Java's String tokenizer does have that I believe C# is lacking (at least Java 7 has this feature) is the ability to keep the delimiter(s) as tokens.  C#'s Split will discard the tokens.  This could be important in say some NLP applications, but for more general purpose applications this might not be a problem.</p>\n"}, {'answer_id': 30768986, 'author': 'Skyler', 'author_id': 4997033, 'author_profile': 'https://Stackoverflow.com/users/4997033', 'pm_score': 2, 'selected': False, 'text': "<pre><code>_words = new List&lt;string&gt;(YourText.ToLower().Trim('\\n', '\\r').Split(' ').\n            Select(x =&gt; new string(x.Where(Char.IsLetter).ToArray()))); \n</code></pre>\n\n<p>Or </p>\n\n<pre><code>_words = new List&lt;string&gt;(YourText.Trim('\\n', '\\r').Split(' ').\n            Select(x =&gt; new string(x.Where(Char.IsLetterOrDigit).ToArray()))); \n</code></pre>\n"}, {'answer_id': 39299866, 'author': 'neronovs', 'author_id': 5771796, 'author_profile': 'https://Stackoverflow.com/users/5771796', 'pm_score': 2, 'selected': False, 'text': "<p>The similar to Java's method is:</p>\n\n<pre><code>Regex.Split(string, pattern);\n</code></pre>\n\n<p>where</p>\n\n<ul>\n<li><code>string</code> - the text you need to split</li>\n<li><code>pattern</code> - string type pattern, what is splitting the text</li>\n</ul>\n"}, {'answer_id': 41133477, 'author': 'Nigel Thomas', 'author_id': 5221568, 'author_profile': 'https://Stackoverflow.com/users/5221568', 'pm_score': -1, 'selected': False, 'text': '<p>If you\'re trying to do something like splitting command line arguments in a .NET Console app, you\'re going to have issues because .NET is either broken or is trying to be clever (which means it\'s as good as broken). I needed to be able to split arguments by the space character, preserving any literals that were quoted so they didn\'t get split in the middle. This is the code I wrote to do the job:</p>\n\n<pre><code>private static List&lt;String&gt; Tokenise(string value, char seperator)\n{\n    List&lt;string&gt; result = new List&lt;string&gt;();\n    value = value.Replace("  ", " ").Replace("  ", " ").Trim();\n    StringBuilder sb = new StringBuilder();\n    bool insideQuote = false;\n    foreach(char c in value.ToCharArray())\n    {\n        if(c == \'"\')\n        {\n            insideQuote = !insideQuote;\n        }\n        if((c == seperator) &amp;&amp; !insideQuote)\n        {\n            if (sb.ToString().Trim().Length &gt; 0)\n            {\n                result.Add(sb.ToString().Trim());\n                sb.Clear();\n            }\n        }\n        else\n        {\n            sb.Append(c);\n        }\n    }\n    if (sb.ToString().Trim().Length &gt; 0)\n    {\n        result.Add(sb.ToString().Trim());\n    }\n\n    return result;\n}\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/70417', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11498/']