Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# Spot the error

Posted on 2000-03-28
Medium Priority
155 Views
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
Question by:pharries
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 3

Accepted Solution

wpsjr1 earned 150 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

ID: 2665809

fnum2=freefile
0

LVL 14

Expert Comment

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

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

## Featured Post

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…
###### Suggested Courses
Course of the Month8 days, 5 hours left to enroll