กระทู้เก่าบอร์ด อ.Yeadram
        
           1,557   2		  
          
					  
		    URL.หัวข้อ / 
		    URL
        
        นำข้อมูลที่หน้าฟอร์ม ไปเก็บลงตาราง      
    
      คือผมต้องการนำข้อมูลที่อยู่หน้าฟอร์ม ไปเก็บไวที่ตาราง ซึ่งผมสร้างตารางไว้ 3 ตาราง โดยที่ต้องคลิกปุ่ม command Button เพียงครั้งเดียว ต้องเขียนคำสั่งอย่างไรครับ
ตัวอย่าง ชื่อตารางมี
Tables1
Tables2
Tables3
ข้อมูลที่อยู่หน้าฟอร์ม มี 3 แถว
แถวที่1 ให้ Text Box = sec223, sec224 ให้ไปอยู่ในตาราง Tables1
แถวที่2 ให้ Text Box = sec333, sec334 ให้ไปอยู่ในตาราง Tables2
แถวที่3 ให้ Text Box = sec443, sec444 ให้ไปอยู่ในตาราง Tables3
แต่คำสั่งที่ผมใช้ก็บันทึกได้แค่ที่ละ ตาราง
ตัวอย่างคำสั่งครับ
Dim myDB As Database
Dim mySet As DAO.Recordset
Set myDB = DBEngine.Workspaces(0).Databases(0)
Set mySet = myDB.OpenRecordset("Tables1", dbOpenDynaset)
mySet.AddNew
mySet![dDiecast 135] = sec223
mySet![dDiecast 250] = sec224
mySet.Update
mySet.Close
myDB.Close
End Sub
ขอบคุณครับ
    
    
  ตัวอย่าง ชื่อตารางมี
Tables1
Tables2
Tables3
ข้อมูลที่อยู่หน้าฟอร์ม มี 3 แถว
แถวที่1 ให้ Text Box = sec223, sec224 ให้ไปอยู่ในตาราง Tables1
แถวที่2 ให้ Text Box = sec333, sec334 ให้ไปอยู่ในตาราง Tables2
แถวที่3 ให้ Text Box = sec443, sec444 ให้ไปอยู่ในตาราง Tables3
แต่คำสั่งที่ผมใช้ก็บันทึกได้แค่ที่ละ ตาราง
ตัวอย่างคำสั่งครับ
Dim myDB As Database
Dim mySet As DAO.Recordset
Set myDB = DBEngine.Workspaces(0).Databases(0)
Set mySet = myDB.OpenRecordset("Tables1", dbOpenDynaset)
mySet.AddNew
mySet![dDiecast 135] = sec223
mySet![dDiecast 250] = sec224
mySet.Update
mySet.Close
myDB.Close
End Sub
ขอบคุณครับ
				2 Reply in this Topic. Dispaly 1  pages and you are on page number 1 
				
        
    2 @R01423    
        
    
      ขอบคุณท่าน อ.สันติสุข  ครับ ใช้ได้แล้วครับ
ขอบคุณมาก ๆ ครับ ที่ให้คำแนะนำ
    
  ขอบคุณมาก ๆ ครับ ที่ให้คำแนะนำ
      Time: 0.0996s
    
      
		
Set mySet ...... "Tables1" ...
...
...
...
mySet.Close
Set mySet ...... "Tables2" ...
...
...
...
mySet.Close
Set mySet ...... "Tables3" ...
...
...
...
mySet.Close