Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dir("") Access2000 - HELP files appear to be wrong Arrgh!

Status
Not open for further replies.

MarkRobinson

Programmer
Feb 18, 2000
112
US
' According to HELP (ya right!) this should list all the<br>' TXT files in the root directory.<br>Private Sub Update_Click()<br>Dim MArray(10) As String<br>mcounter = 1<br>'get first .TXT file in root <br>MArray(mcounter) = Dir(&quot;C:\*.txt&quot;)<br>Do While mcounter &lt; 10<br>&nbsp;&nbsp;&nbsp;&nbsp;Debug.Print MArray(mcounter)<br>&nbsp;&nbsp;&nbsp;&nbsp;mcounter = mcounter + 1<br>&nbsp;&nbsp;&nbsp;&nbsp;' According to HELP, this should<br>&nbsp;&nbsp;&nbsp;&nbsp;' get subsequent files.<br>&nbsp;&nbsp;&nbsp;&nbsp;' All it does is keep getting<br>&nbsp;&nbsp;&nbsp;&nbsp;' the second file<br>&nbsp;&nbsp;&nbsp;&nbsp;MArray(mcounter) = Dir(&quot;*.TXT&quot;)<br>Loop<br>End Sub<br>
 
A couple of things:<br>1. Do you have any .TXT file in the root of C:\?<br>2. Press Ctrl-G To bring up the Debug window, Cause that's where the results are going..&gt; &quot;Debug.Print MArray(mcounter)&quot;. While you are in the VBA code window Press Ctrl-G, then set your form to Not Maximized so you can see the Debug window while it runs.<br>3. you are missing a Dimension statement..&gt; Dim mcounter As Integer<br><br>I pasted your code in Access 2000 and it works if you do those 3 things. <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
How is this possible?<br>Dim MArray(10) As String<br>Dim mcounter As Integer<br><br>mcounter = 1<br>'get first .TXT file in root<br>MArray(mcounter) = Dir(&quot;C:\*.txt&quot;)<br>Do While mcounter &lt; 10<br>&nbsp;&nbsp;&nbsp;&nbsp;Debug.Print mcounter<br>&nbsp;&nbsp;&nbsp;&nbsp;Debug.Print MArray(mcounter)<br>&nbsp;&nbsp;&nbsp;&nbsp;mcounter = mcounter + 1<br>&nbsp;&nbsp;&nbsp;&nbsp;' According to HELP, should<br>&nbsp;&nbsp;&nbsp;&nbsp;' get subsequent files.<br>&nbsp;&nbsp;&nbsp;&nbsp;' All it does is keep getting<br>&nbsp;&nbsp;&nbsp;&nbsp;' the second file<br>&nbsp;&nbsp;&nbsp;&nbsp;MArray(mcounter) = Dir(&quot;&quot;)<br>Loop<br><br>I keep getting the first .TXT file, then 9 other listings of the same non .TXT files... regardless of whether the last command is Dir=(&quot;&quot;) like the instructions say or dir(&quot;*.TXT&quot;)<br>I know I have several .TXT files in the root.<br>Can't even imagine how to troubleshoot it.<br>Hmmmmm
 
The second reference to the Dir function should be Dir(). <p>Jim Conrad<br><a href=mailto:JimConrad@Consultant.com>JimConrad@Consultant.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top