[AccessD] Load from test AGAIN

MartyConnelly martyconnelly at shaw.ca
Wed Oct 18 15:31:22 CDT 2006


This works for me
assuming file names are in this style of template
"C:\Access files\Forms\Form_MySinging.txt

I found  an unfinished mda that does most of this.
going both ways load and save, if you want a look see
Lacks some error checking etc.


Public Sub loadup()
On Error GoTo Err_loadup
Dim strTemp As String
Dim strName As String
Dim strDir As String
strDir = "C:\Access files\Forms\"
strTemp = Dir(strDir & "*.txt")
Do Until strTemp = ""
Debug.Print UCase(Left(strTemp, 4))
  'remove file name extension
  strName = Mid(strTemp, 1, InStrRev(strTemp, ".", -1, vbTextCompare) - 1)
        Select Case UCase(Left(strTemp, 4))
      
                Case "FORM"
                Debug.Print strTemp; strName
                 ' 'remove file name prefix "Form_"
                Application.LoadFromText acForm, Mid(strName, InStr(1, 
strName, "_", vbTextCompare) + 1), strDir & strTemp
                Case "REPO"
                Application.LoadFromText acReport, "test", strDir & strTemp
        End Select
        strTemp = Dir
Loop
Exit_loadup:
Exit Sub
Err_loadup:
        MsgBox Err.Description, Err.Number
        Resume Exit_loadup
    Resume 0    '.FOR TROUBLESHOOTING
End Sub

Martin Reid wrote:

>Ok this has me beat
> 
>No matter what I try I cant get it to loop through a folder and import the exported text files. Tried Martys stuff, Drews stuff and my own. Used file system object to return only the file name without the extension and no luck.
>
>Any help greatly appreciated.
> 
>background
> 
>Access database objects exported as text files into C\|Forms
> 
>I think need to LoadFromText all the objects in said folder back into database.
> 
>This cannot be as difficult as it seems. One at a time and naming the files it works. Only when I go to look through all the objects does it fail. This is almost my last example file I need and its melting my head.
> 
> 
>Martin
> 
> 
> 
>Martin WP Reid
>Training and Assessment Unit
>Riddle Hall
>Belfast
> 
>tel: 02890 974477
> 
>  
>
>------------------------------------------------------------------------
>
>No virus found in this incoming message.
>Checked by AVG Free Edition.
>Version: 7.1.408 / Virus Database: 268.13.5/483 - Release Date: 18/10/2006
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada




More information about the AccessD mailing list