Select data in a combobox in a subform
กระทู้เก่าบอร์ด อ.สุภาพ ไชยา

 266   1
URL.หัวข้อ / URL
Select data in a combobox in a subform

มีคนถามไว้ที่ 
http://www.utteraccess.com/forums/showflat.php?Cat=&Board=access_2000&Number=109946&page=0&view=collapsed&sb=5&o=7&fpart=1&vc=1&PHPSESSID= 
 
ดังนี้ 
Hi, 
 
I'm working on a database in which I can store all data regarding the network  
I'm administering. 
 
I've got it allmost working exept for one detail. I've attached the database. (It is  
in dutch but that shouldn't matter) 
 
On the form "Software" there is a subform "Subformulier Relatie Software- 
Computer" In this form show a field called "Id Licentie". Now when selected the  
field shows a combobox listing all available Licence numbers. This in not  
exactly what I want. The combobox should list only the available Licence  
numbers for the selected software in the mainform. 
 
I think a SQL-instruction should do the trick but I can't figure it out.  
 
If someone could help it, it is greatly appreciated. 
 
เขามีตัวอย่างไฟล์จริงมาให้ด้วยครับ ที่ http://www.utteraccess.com/forums/uploads/109912-Netwerk-V1.0.mdb 
 
เขาถามว่า ต้องการให้ Combo Box ชื่อ id computer ซึ่งอยู่ใน Sub Form แสดงรายการที่เกี่ยวข้องเฉพาะกับ ID ของฟอร์มหลักเท่านั้น จะทำอย่างไร เพราะตอนนี้มันแสดงขึ้นมาหมดเลย 
 
ลองเอามาดูแล้วปรับตามคำที่ผมแนะนำเขาไปนะครับ คือ 
 
1. เปลี่ยน Row Source ของ ID Computer combo box ด้วย SQL ข้างล่าง 
 
SELECT Computers.Id, Computers.[Computer id], Computers.Locatie 
FROM Computers 
WHERE (((Computers.Id)=[Forms]![SoftWare]![ID])); 
 
2. แล้วใส่โค้ดข้างล่างลงไปในเหตุการณ์ On Current ของฟอร์มหลัก เพื่อ REFRESH รายการที่จะแสดงใน ID Computer combo box ครับ 
 
code:-------------------------------------------------------------------------------- 
Private Sub Form_Current() 
    Me.[Subformulier Relatie Software-Computer1].Form.[id computer].Requery 
End Sub 
code:-------------------------------------------------------------------------------- 
 
*** Edited by Supap Chaiya *** 11/6/2546 17:13:12

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

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