Little program, BIG HELP!!
กระทู้เก่าบอร์ด อ.สุภาพ ไชยา

 250   1
URL.หัวข้อ / URL
Little program, BIG HELP!!

มีคนถามไว้ที่ http://www.quicktechusa.com/msgboard/wwwboard.pl?read=20883 
ดังนี้ 
 
HI everybody, and thanks for this priceless forum.  
 
I'm developing a small web page, I have no money to pay a programmer to solve this little problem for any access programmer but a huge problem for me (an absolute access ignorant).  
 
My problem is:  
 
My Table:  
NAME         CODE  
blue               The best blue  
green               Emerald like  
red                 Red, Red, whine  
 
What I need is access create a set of .txt files  
with CODE as data and NAME as name of the file.  
 
Ex. blue.txt, green.txt, etc.  
 
If somebody please can give me some kind of step by step guide I will really appreciate that.  
 
PS> Or maybe I don't need access to do this and I can use any other program, please let me know.  
 
Best Regards, Alfredo  
 
สรุปคำถาม 
มีตารางอยู่ 1 ตาราง ต้องการจะนำไปสร้างเป็น Text File โดยให้เอาข้อมุลในฟีลด์ชื่อ Name ไปตั้งเป็นชื่อไฟล์ และให้เขียนข้อมูลในฟีลด์ชื่อ Code ไปในไฟล์ดังกล่าว 
 
ผมเลยได้สร้างโค้ดตามตัวอย่างข้างล่าง โดยจะสร้างไฟล์ไปไว้ในห้อง C: ดังนี้ 
 
Sub CreateTextFile() 
Dim dbs As Database, rst As Recordset, I As Integer 
Set dbs = CurrentDb 
Set rst = dbs.OpenRecordset("table1") 
If Not rst.EOF Then 
    For I = 1 To rst.RecordCount 
    Open "c:\" & rst("Name") & ".txt" For Output As #1 
        Print #1, rst("Code") 
        Close #1 
        rst.MoveNext 
    Next I 
End If 
 
rst.Close 
dbs.Close 
 
End Sub 
 
ไฟล์ตัวอย่างจริงอยู่ที่ http://agserver.kku.ac.th/basiceng/scriptingfile2.zip ครับ 
 

1 Reply in this Topic. Dispaly 1 pages and you are on page number 1

1 @R00228
ขอบพระคุณ อ.สุภาพ มากๆ ครับ สำหรับความรู้ดีๆ ด้วยความเคารพ และนับถือ
@ ประกาศใช้งานเว็บบอร์ดใหม่ => บอร์ดเรียนรู้ Access สำหรับคนไทย
แล้วจะใส่ลิ้งอ้างอิงมาที่โพสต์เก่านี้หรือไม่ก็ตามสะดวกครับ
Time: 0.0542s