My Assistant
![]() ![]() |
|
|
Mar 19 2007, 09:30 AM
Post
#1
|
|
|
UtterAccess Guru Posts: 561 From: Connecticut, New England |
Good Morning,
I found some code that loops through a DB and saves all the forms out as text. (I was having corruption issues) I am now trying to write some code to loop through the directory where I saved all my forms at .txt files and do a LoadFromText. I think I have the code fine but I am getting an error message 2220; cannot open file ? In the screenprint below you can see both the code I used to SaveAsText and the LoadFromText as well. I am able to manually open any of these .txt files myself so why is my code locking up ?? Thanks, J. (IMG:http://i114.photobucket.com/albums/n244/JoeOxfordCT/LoadFromText.jpg) |
|
|
|
Mar 19 2007, 10:23 AM
Post
#2
|
|
|
UtterAccess VIP Posts: 5,508 From: Brixton, front line |
Hi Joe,
I can't tell from here, but are you passing the full path to the file or just the file name? Perhaps try: Application.LoadFromText acForm, R, "C:\Forms\" & strFile hth, d |
|
|
|
Mar 19 2007, 10:32 AM
Post
#3
|
|
|
UtterAccess Guru Posts: 561 From: Connecticut, New England |
Thanks d,
That solved that problem but not I can't seem to get the loop to go through all the files....it seems to just do the first .txt file over and over again. Here's my updated code: (I commented out the LoadFromText line because I just wanted to see the loop run) CODE Public Function LoadFormText()
Dim strFile As String strFile = Dir("C:\Forms\*.txt") Dim R As String R = Left(strFile, Len(strFile) - 4) Do While strFile <> "" strFile = Dir 'Application.LoadFromText acForm, R, "C:\Forms\" & strFile MsgBox R Loop MsgBox "Import of Forms complete !!" End Function |
|
|
|
Mar 19 2007, 10:35 AM
Post
#4
|
|
|
UtterAccess VIP Posts: 5,508 From: Brixton, front line |
Hi, you are not reassigning the value of R
CODE Public Function LoadFormText() Dim strFile As String strFile = Dir("C:\Forms\*.txt") Dim R As String Do While strFile <> "" strFile = Dir R = Left(strFile, Len(strFile) - 4) [color="green"]' <--- Do it here! 'Application.LoadFromText acForm, R, "C:\Forms\" & strFile MsgBox R Loop MsgBox "Import of Forms complete !!" End Function hth, d |
|
|
|
Mar 19 2007, 10:36 AM
Post
#5
|
|
|
UtterAccess VIP Posts: 5,508 From: Brixton, front line |
Oops! forgot the close colour tag! But I think you can see what I'm getting at.
d |
|
|
|
Mar 19 2007, 11:21 AM
Post
#6
|
|
|
UtterAccess Guru Posts: 561 From: Connecticut, New England |
Whoops....uh, I knew that.... (IMG:http://www.utteraccess.com/forum/style_emoticons/default/blush.gif)
Thanks very much ! I think that's got it now.... |
|
|
|
Mar 19 2007, 11:32 AM
Post
#7
|
|
|
UtterAccess VIP Posts: 5,508 From: Brixton, front line |
|
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 19th June 2013 - 01:53 PM |