Updating Data Between Form Controls
กระทู้เก่าบอร์ด อ.สุภาพ ไชยา

 274   1
URL.หัวข้อ / URL
Updating Data Between Form Controls

http://www.access-programmers.co.uk/forums/showthread.php?s=&postid=108117#post108117 
 
I have 2 forms, Form “A” and Form “B”. I Update data in Form “A” while Form “B”  
is closed, when I open Form “B” all the updated data is in the controls. If I try to  
update the data in Form “A” while Form “B” is open, the data does not appear in  
the controls of Form “B”. I add the following code in form “A”  
 
Private Sub Form_AfterUpdate()  
Forms![F_SearchParts]![Combo10].Requery  
Forms![F_SearchParts]![Combo14].Requery  
Forms![F_SearchParts]![Combo16].Requery  
Forms![F_SearchParts]![Combo20].Requery  
End Sub  
 
While both forms are open Form “B” updates OK. Now if I try to update Form “A”  
with Form “B” closed, I receive an error message because I have not opened  
Form “B”, I can overcome this by opening Form “B” using code then not making  
the form visible. My question- “Is there a way to update Form “B” no matter if it is  
open or closed.” I would appreciate any advise.  
 
kevsim 
 
สรุป มีฟอร์ม A และ B เปิดพร้อมกันอยู่ เมื่อใส่ข้อมูลในฟอร์ม A ต้องการให้ข้อมูลในฟอร์ม B ปรับปรุงด้วย ซึ่งทำได้ไม่มีปัญหา แต่ถ้าฟอร์ม B ปิดอยู่ จะเกิด Error จะแก้ปัญหานี้อย่างไร 
 
ผมนึกถึงฟังก์ชัน IsLoaded() ที่มากับไฟล์ตัวอย่าง Northwind.mdb ทันที เพื่อมาตรวจดูว่าฟอร์ม B เปิดอยู่หรือไม่ โดยเพิ่มโค้ดเข้าไปดังนี้ 
 
Function IsLoaded(ByVal strFormName As String) As Boolean  
' Returns True if the specified form is open in Form view or Datasheet view.  
 
Const conObjStateClosed = 0  
Const conDesignView = 0  
 
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then  
    If Forms(strFormName).CurrentView <> conDesignView Then  
         IsLoaded = True  
    End If  
End If  
 
End Function  
 
Private Sub Form_AfterUpdate()  
If IsLoaded("F_SearchParts") = True Then  
     Forms![F_SearchParts]![Combo10].Requery  
     Forms![F_SearchParts]![Combo14].Requery  
     Forms![F_SearchParts]![Combo16].Requery  
     Forms![F_SearchParts]![Combo20].Requery  
End If  
End Sub 

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

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