Solved

Spot the error

Posted on 2000-03-28
4
144 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

706 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

19 Experts available now in Live!

Get 1:1 Help Now