textbox แสดงข้อความ #Name? แก้ยังไงครับ
กระทู้เก่าบอร์ด อ.Yeadram

 1,713   5
URL.หัวข้อ / URL
textbox แสดงข้อความ #Name? แก้ยังไงครับ

ผมสร้าง Form และเขียน code VBA

มีปัญหาตรงที่เมื่อเปิดฐานข้อมูลขึ้นมา textbox ที่เชื่อมกับ combobox ขึ้นว่า #Name?
textbox กำหนด control source ว่า =[item01].[column](1)
combobox เชื่อมกับ Table มี 2 field (field ที่ 1 เป็นรายการ, field ที่ 2 เป็นราคา)

วิธีแก้ปัญหาเบื้องต้นคือ
เข้ามุมมองออกแบบ แล้วให้แสดง code
ปิดแล้วกลับมามุมมอง Form อีกครั้ง
textbox ที่แสดง #Name? ก็จะหายไป จะแสดงค่าที่เขียน code ไว้ให้แสดงอย่างปกติ
ฐานข้อมูลนี้ออกแบบให้ใช้หลายคน วิธีแก้เบื้องต้นอาจเผลอไปลบ code ได้ครับ

ตอนแรกไม่เป็นนะครับ พอปรับปรุงไปเรื่อยๆก็เป็นซะอย่างนั้น รบกวนขอคำแนะนำด้วยครับ

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

1 @R21927
code สำหรับ Form นี้ทั้งหมด อย่างอื่นใช้ macro ครับ


Private Sub prz01_AfterUpdate()
Mycalculate
End Sub

Private Sub unit01_AfterUpdate()
Mycalculate
End Sub

Private Sub prz02_AfterUpdate()
Mycalculate
End Sub

Private Sub unit02_AfterUpdate()
Mycalculate
End Sub

Private Sub prz03_AfterUpdate()
Mycalculate
End Sub

Private Sub unit03_AfterUpdate()
Mycalculate
End Sub

Private Sub prz04_AfterUpdate()
Mycalculate
End Sub

Private Sub unit04_AfterUpdate()
Mycalculate
End Sub

Private Sub prz05_AfterUpdate()
Mycalculate
End Sub

Private Sub unit05_AfterUpdate()
Mycalculate
End Sub

Private Sub prz06_AfterUpdate()
Mycalculate
End Sub

Private Sub unit06_AfterUpdate()
Mycalculate
End Sub

Private Sub prz07_AfterUpdate()
Mycalculate
End Sub

Private Sub unit07_AfterUpdate()
Mycalculate
End Sub

Private Sub prz08_AfterUpdate()
Mycalculate
End Sub

Private Sub unit08_AfterUpdate()
Mycalculate
End Sub

Private Sub prz09_AfterUpdate()
Mycalculate
End Sub

Private Sub unit09_AfterUpdate()
Mycalculate
End Sub

Private Sub prz10_AfterUpdate()
Mycalculate
End Sub

Private Sub unit10_AfterUpdate()
Mycalculate
End Sub

Private Sub prz11_AfterUpdate()
Mycalculate
End Sub

Private Sub unit11_AfterUpdate()
Mycalculate
End Sub

Private Sub prz12_AfterUpdate()
Mycalculate
End Sub

Private Sub unit12_AfterUpdate()
Mycalculate
End Sub

Private Sub prz13_AfterUpdate()
Mycalculate
End Sub

Private Sub unit13_AfterUpdate()
Mycalculate
End Sub

Private Sub prz14_AfterUpdate()
Mycalculate
End Sub

Private Sub unit14_AfterUpdate()
Mycalculate
End Sub

Private Sub prz15_AfterUpdate()
Mycalculate
End Sub

Private Sub unit15_AfterUpdate()
Mycalculate
End Sub

Sub Mycalculate()
If prz01 = "" Then prz01 = 0
If unit01 = "" Then unit01 = 0
Me.cost01 = prz01 * unit01
If prz02 = "" Then prz02 = 0
If unit02 = "" Then unit02 = 0
Me.cost02 = prz02 * unit02
If prz03 = "" Then prz03 = 0
If unit03 = "" Then unit03 = 0
Me.cost03 = prz03 * unit03
If prz04 = "" Then prz04 = 0
If unit04 = "" Then unit04 = 0
Me.cost04 = prz04 * unit04
If prz05 = "" Then prz05 = 0
If unit05 = "" Then unit05 = 0
Me.cost05 = prz05 * unit05
If prz06 = "" Then prz06 = 0
If unit06 = "" Then unit06 = 0
Me.cost06 = prz06 * unit06
If prz07 = "" Then prz07 = 0
If unit07 = "" Then unit07 = 0
Me.cost07 = prz07 * unit07
If prz08 = "" Then prz08 = 0
If unit08 = "" Then unit08 = 0
Me.cost08 = prz08 * unit08
If prz09 = "" Then prz09 = 0
If unit09 = "" Then unit09 = 0
Me.cost09 = prz09 * unit09
If prz10 = "" Then prz10 = 0
If unit10 = "" Then unit10 = 0
Me.cost10 = prz10 * unit10
If prz11 = "" Then prz11 = 0
If unit11 = "" Then unit11 = 0
Me.cost11 = prz11 * unit11
If prz12 = "" Then prz12 = 0
If unit12 = "" Then unit12 = 0
Me.cost12 = prz12 * unit12
If prz13 = "" Then prz13 = 0
If unit13 = "" Then unit13 = 0
Me.cost13 = prz13 * unit13
If prz14 = "" Then prz14 = 0
If unit14 = "" Then unit14 = 0
Me.cost14 = prz14 * unit14
If prz15 = "" Then prz15 = 0
If unit15 = "" Then unit15 = 0
Me.cost15 = prz15 * unit15
If cost01 = "" Then cost01 = 0
If cost02 = "" Then cost02 = 0
If cost03 = "" Then cost03 = 0
If cost04 = "" Then cost04 = 0
If cost05 = "" Then cost05 = 0
If cost06 = "" Then cost06 = 0
If cost07 = "" Then cost07 = 0
If cost08 = "" Then cost08 = 0
If cost09 = "" Then cost09 = 0
If cost10 = "" Then cost10 = 0
If cost11 = "" Then cost11 = 0
If cost12 = "" Then cost12 = 0
If cost13 = "" Then cost13 = 0
If cost14 = "" Then cost14 = 0
If cost15 = "" Then cost15 = 0
Me.sum = cost01 + cost02 + cost03 + cost04 + cost05 + cost06 + cost07 + cost08 + cost09 + cost10 + cost11 + cost12 + cost13 + cost14 + cost15
End Sub
2 @R21947
จากโค้ดที่นำมาแสดง ไม่น่าจะทำให้เกิดปัญหาที่ว่า น่าจะเกิดจากโค้ดหรือแมโครที่อื่นครับ
3 @R21990
แก้ไขได้แล้วครับ ลองกระชับฐานข้อมูลก็หายเลย
ขอบคุณอาจารย์ครับ
4 @R22002
เป็นเหมือนกันเลยค่ะ ยังไม่รุ้จะแก้ยังไง
5 @R22003
เกิดเพราะ ControlSource อาจจะ
1. เขียนชื่อฟิลด์ ชื่อคอนโทรล ชื่อ Property หรือชื่อฟังก์ชั่นผิด
2. ถ้าชื่อที่อ้าง มีช่องว่างในชื่อ ต้องคร่อมชื่อด้วยเครื่องหมาย [ ]
3. กรณีอ้างถึง Property ของคอนโทรลอื่น หรืออ้างถึงฟังก์ชั่น ต้องมีเครื่องหมาย = (เท่ากับ) น้ำหน้า
@ ประกาศใช้งานเว็บบอร์ดใหม่ => บอร์ดเรียนรู้ Access สำหรับคนไทย
แล้วจะใส่ลิ้งอ้างอิงมาที่โพสต์เก่านี้หรือไม่ก็ตามสะดวกครับ
Time: 0.3410s