Solved

Whille loop not going to next script text file.

Posted on 2011-09-20
3
265 Views
Last Modified: 2012-05-12
I think Its me, but the below simply repeatedly loops through and gets only the first script.  I am a little puzzled as to how to tell it to go to the next script text file, it is my understand the While should do it, but I think I messed up teh code and can't get it to work.
Private Sub Recovery()
'Recovers objects for a specific database.
Dim txtPath
Dim txtFile
Dim strObjectName As String

txtPath = "K:\DatabaseDevelopment\DBScripts_RegE\"
txtFile = Dir(txtPath & "*.txt")

While txtFile <> ""
   Select Case Left(txtFile, InStr(txtFile, "_") - 1)
         Case "Form"
            strObjectName = Left(Mid(txtFile, InStr(1, txtFile, "_") + 1), InStr(1, Mid(txtFile, InStr(1, txtFile, "_") + 1), ".") - 1)
            Application.LoadFromText acForm, strObjectName, txtPath & txtFile
            MsgBox "Form: " & strObjectName & " has been imported.", vbOKOnly
         Case "Table"

         'etc...
   End Select
Wend

End Sub

Open in new window

0
Comment
Question by:ssmith94015
3 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 36568231


While txtFile <> ""
   Select Case Left(txtFile, InStr(txtFile, "_") - 1)
         Case "Form"
            strObjectName = Left(Mid(txtFile, InStr(1, txtFile, "_") + 1), InStr(1, Mid(txtFile, InStr(1, txtFile, "_") + 1), ".") - 1)
            Application.LoadFromText acForm, strObjectName, txtPath & txtFile
            MsgBox "Form: " & strObjectName & " has been imported.", vbOKOnly
         Case "Table"

         'etc...
   End Select

     txtFile=dir  'ADD this
Wend
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 36568306
have a look at this link to get more info on Dir() usage:

http://www.techonthenet.com/access/functions/file/dir.php

MS Access: Dir Function : Dir [( path [, attributes ] ) ]

Dir function returns the first filename that matches the pathname and attributes specified. To retrieve additional filenames that match pathname and attributes, call Dir again with no arguments.



0
 

Author Closing Comment

by:ssmith94015
ID: 36568361
Cap, that was it.  Thank you both.

Sandra
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
MS Access 2003 or later To MySQL Migration Project Hello All, this is my second article in the category of MS-OFFICE Automation. In internet I am not able to find any comprehensive resource on the Migration of MS Access back-end to MySQL so I fin…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now