Mschart scale/access ใน Report ?
กระทู้เก่าบอร์ด อ.สุภาพ ไชยา

 237   4
URL.หัวข้อ / URL
Mschart scale/access ใน Report ?

อ.สุภาพครับผมไม่ค่อยเข้าใจในการเขียนโค๊ดใน report เลยครับช่วยชี้แจงหน่อยนะครับ
ทำไมเราเขียน Code แล้วมันไม่ขึ้น Systex ให้ละครับ?
เมื่อเรา Run แล้วมันฟ้องว่าไม่สามารถกำนดค่า Object นี้ได้
แล้วผมจะกำหนด Scale กราฟอ่างไรละครับ

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

1 @R05135
ลองเอาโค้ดที่ว่ามาดูครับ
2 @R05139
Private Sub Report_Open(Cancel As Integer)
Dim E1LL As Double
Dim E1HL As Double
Dim E1SD As Double
Dim E1LowS As Double
Dim E1HighS As Double
E1SD = DLookup("SD", "FileControl", "[Test]='ALP' and [Gen]=IGALP.Value and [LotControl]=C1controlLot.Value and [level]='E1'")
E1LL = DLookup("Low", "FileControl", "[Test]='ALP' and [Gen]=IGALP.Value and [LotControl]=C1controlLot.Value and [level]='E1'")
E1HL = DLookup("High", "FileControl", "[Test]='ALP' and [Gen]=IGALP.Value and [LotControl]=C1controlLot.Value and [level]='E1'")
E1LowS = E1LL - (1.5 * E1SD)
E1HighS = (1.5 * E1SD) + E1HL
Me![GE1].Object.Application.Chart.axes(2).minimumscale = CDbl(E1LowS)
Me![GE1].Object.Application.Chart.axes(2).maximumscale = CDbl(E1HighS)
GE1.Requery
Dim E2LL As Double
Dim E2HL As Double
Dim E2SD As Double
Dim E2LowS As Double
Dim E2HighS As Double
E2SD = DLookup("SD", "FileControl", "[Test]='ALP' and [Gen]=IGALP.Value and [LotControl]=C2controlLot.Value and [level]='E2'")
E2LL = DLookup("Low", "FileControl", "[Test]='ALP' and [Gen]=IGALP.Value and [LotControl]=C2controlLot.Value and [level]='E2'")
E2HL = DLookup("High", "FileControl", "[Test]='ALP' and [Gen]=IGALP.Value and [LotControl]=C2controlLot.Value and [level]='E2'")
E2LowS = E2LL - (1.5 * E2SD)
E2HighS = (1.5 * E2SD) + E2HL
Me![GE2].Object.Application.Chart.axes(2).minimumscale = CDbl(E2LowS)
Me![GE2].Object.Application.Chart.axes(2).maximumscale = CDbl(E2HighS)
GE2.Requery
End Sub
3 @R05140
C1controlLot เป็น Control หนึ่งใน Report ปัจจุบันหรือเปล่าครับ

ลองเปลี่ยนการกำหนด Where clause ใน DLookup() ใหม่ครับ

E1SD = DLookup("SD", "FileControl", "[Test]='ALP' and [Gen]= '" & IGALP.Value & "' and [LotControl]= " & C1controlLot.Value & " and [level]='E1'")

ดูว่า Gen และ LotControl เป็นฟีลด์ประเภทไหน แล้วเปลี่ยนการอ้างอิงให้ตรงกับฟีลด์เป้าหมายด้วยครับ

4 @R05143
ผมใช้ Code เดียวกันกับ Form นะครับแต่ที่ Form นะใช้ได้
ผมใส่ที่ Private Sub Report_Open(Cancel As Integer)
ถูกแล้วใช่ไหมครับ
เห็นบางทีต้องใส่ที่ Function เป็น Module นะครับ
@ ประกาศใช้งานเว็บบอร์ดใหม่ => บอร์ดเรียนรู้ Access สำหรับคนไทย
แล้วจะใส่ลิ้งอ้างอิงมาที่โพสต์เก่านี้หรือไม่ก็ตามสะดวกครับ
Time: 0.0394s