Solved

Spot the error

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

912 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

16 Experts available now in Live!

Get 1:1 Help Now