Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordset Problem 1

Status
Not open for further replies.

bousair

Technical User
Jan 16, 2002
5
NL
plz can you help me, with this code?
The loop doesn't want to work. My table containts 300 records, so the code must generate 300 txt files, with different names. I tried it in ACCESS 97 & 2002, but i still keep the problem.....
thank you in advance.

***********************
Dim dbs As DAO.Database
Dim name As String
Dim funct As String
Dim rs As DAO.Recordset
Dim strfile As String
Set dbs = CurrentDb
Set rs = dbs.OpenRecordset("adrmp", dbOpenForwardOnly)

funct = rs.Fields("adr010")
name = rs.Fields("adr020")

Do
strfile = "c:\test\" & name & ".txt"
Open strfile For Output As #1
Print #1, naam
Close #1

rs.MoveNext
Loop Until rs.EOF
 
sorry it's
Print #1, name

but that is not the problem...
 
well the way you have it now, your name variable is never going to change. it's going to be equal to the first record returned for field "adr020." try putting
Code:
name = rs.Fields("adr020")

inside your do while loop for starters, just to get the name to change and thus create new files.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top