ต้องการ Loop ชื่อตาราง ชื่อฟิลด์ โดยใช้ชื่อจากตาราง tbTarang1 ดังรูป


0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

14 ต.ค. 63 , 13:16:45
อ่าน 617 ครั้ง

nonc31


 

14 ต.ค. 63 , 15:36:55
ตอบกลับ #1

PNR

ต้อง Open Record set จากชื่อ FName เลยครับ
แล้วมา Loop เดี่ยวทำให้ครับ
Time to stop for me  :dizzy:
 

14 ต.ค. 63 , 16:07:43
ตอบกลับ #2

PNR

น่าจะแบบนี้ครับ
โค๊ด: [Select]
Sub FieldNames()
    Dim rst, rstOut, strTable  As Recordset
    Dim f As Field
    Dim SQL, RecordName As String
   
    Set rst = CurrentDb.OpenRecordset("tbTarang1")
    Set rstOut = CurrentDb.OpenRecordset("tbfild1")
        rst.MoveFirst
        Do Until rst.EOF
            RecordName = rst!fname
    Set strTable = CurrentDb.OpenRecordset(RecordName)
            For Each f In strTable.Fields
                rstOut.AddNew
                rstOut![tarang] = RecordName
                rstOut![fild] = f.Name
                rstOut.Update
            Next
        rst.MoveNext
        Loop
    rst.Close: Set rst = Nothing
    rstOut.Close: Set rstOut = Nothing
    strTable.Close: Set strTable = Nothing
End Sub
« แก้ไขครั้งสุดท้าย: 15 ต.ค. 63 , 08:16:49 โดย PNR »
Time to stop for me  :dizzy:
 
โพสต์นี้ได้รับคำขอบคุณจาก: sjs, nonc31

14 ต.ค. 63 , 20:40:34
ตอบกลับ #3

nonc31

ขอบคุณครับ  ตามต้องการเลย

 


บอร์ดเรียนรู้ Access สำหรับคนไทย


 

Sitemap 1 2 3 4 5