Solved

Spot the error

Posted on 2000-03-28
4
146 Views
Last Modified: 2010-05-02
I thinkk there is something wrong with my loops.
This is an access module


Public Function chapter_outputfinal_Gill()

    Dim d As Database
     Dim r As Recordset
     Dim fNum As Integer
     Dim i As Integer

     Set d = CurrentDb
     Set r = d.OpenRecordset("final_gill")

     Do Until r.EOF

          fNum = FreeFile
          i = i + 1
         
Open "f:\gill\" & r!book_ & "\" & r!book_ & "_" & r!ch & ".htm" For Output As fNum


Open "g:\Gill\" & r!bk & "\" & r!bk & "_" & r!ch & ".htm" For Input As #2


              Do While Not EOF(2)
              Line Input #2, MyString
              Print #fNum, MyString
              Loop
     Close #2
     Close fNum
     r.MoveNext
           
     Loop

     Set r = Nothing
     Set d = Nothing


End Function


0
Comment
Question by:pharries
4 Comments
 
LVL 3

Accepted Solution

by:
wpsjr1 earned 50 total points
ID: 2665756
Move Close #2 and Close fNum  outside of the Loop.

Enjoy!  :)

Paul

http://www.syix.com/wpsjr1/index.html
0
 
LVL 2

Expert Comment

by:sbmc
ID: 2665809
Also instead of #2 use fnum2. After your first open

fnum2=freefile
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2666084
A little housekeeping for ya.. and a couple of enhancements / corrections.. <smile>

<----- Code Begin ----->

Public Function chapter_outputfinal_Gill()

   Dim db As Database
   Dim rs As Recordset
   Dim intFile1 As Integer
   Dim strFile1 As String
   Dim intFile2 As Integer
   Dim strFile2 As String
   Dim strWork As String
   
   intFile1 = FreeFile
   intFile2 = FreeFile
   
   Set db = CurrentDb
   Set rs = db.OpenRecordset("final_gill")
   
   Do Until rs.EOF
       
      strFile1 = "f:\gill\" _
         & r!book & "\" _
         & r!book & "_" & r!ch _
         & ".htm"
      Open strFile1 For Append As intFile1
     
      strFile2 = "g:\Gill\" _
         & r!bk & "\" _
         & r!bk & "_" & r!ch _
         & ".htm"
      Open strFile2 For Binary As intFile2
     
      strWork = Space(LOF(intFile2))
      Get intFile2, , strWork
      Put intFile1, , strWork
     
      Close intFile1
      Close intFile2
     
      rs.MoveNext
         
   Loop

   rs.Close
   Set rs = Nothing
   Set db = Nothing
   
End Function

<----- Code End ----->
0
 

Author Comment

by:pharries
ID: 2669588
Sorry the script was fine
I was just looking in the wrong place!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

813 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

10 Experts available now in Live!

Get 1:1 Help Now