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

เริ่มโดย nonc31, 14 ต.ค 20 , 13:16:45

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

nonc31

  •  

PNR

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

PNR

น่าจะแบบนี้ครับ
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
Time to stop for me  :dizzy:
  •  
    โพสต์นี้ได้รับคำขอบคุณจาก: sjs, nonc31

nonc31

  •