แสดงกระทู้

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - PNR

หน้า: 1 ... 20 21 22 [23] 24 25 26 ... 46
397
ส่งค่าไปอีกตารางก็เหมือนส่งจดหมายนะครับถ้าไม่มีที่อยู่ที่ชัดเจนและจะรู้ได้ยังไงว่าจะไปส่งถูกที่
จากคำถามของผมคุณคิดว่าจะนำไปวางยังไงครับ ลองอธิบายนิดนึง

398
มีฟิลล์ไหนไม่ซ้ำไหม

399
iCustCode เป็นข้อมูลที่ซ้ำกันไหม

400
ห้อง MS Access / : รวมฟิวส์ Text
« เมื่อ: 31 ส.ค. 63 , 16:03:16 »
เราสามารถที่จะพอทำได้ครับ โดยใช้การกำหนด ประกาศตัวแปรเป็น Public นะครับ
ผมสมมุติ text1 ถึง text3 และ textbox แสดงชื่อ total
เพราะโดยปกติ .Text จะใช้ได้กับ คอนโทรลที่ โฟกัสอยู่เท่านั้น
เราจึงควรสร้างตัวแปรขึ้นมาเก็บค่าไว้ก่อนเพื่อนำไปต่อกับ ตัวแปรต่อๆไป ครับ

ดังตัวอย่างโค้ดนี้

โค๊ด: [Select]
Option Compare Database
Public strText1, strText2, strText3 As Variant

Private Sub Form_Current()
Me.total = strText1 & " " & strText2 & " " & strText3
End Sub

Private Sub Text1_Change()
If Len(Me.Text1.Text) > 0 Then
strText1 = Me.Text1.Text
End If
Me.total = strText1 & " " & strText2 & " " & strText3
End Sub
Private Sub Text2_Change()
If Len(Me.Text2.Text) > 0 Then
strText2 = Me.Text2.Text
End If
Me.total = strText1 & " " & strText2 & " " & strText3
End Sub
Private Sub Text3_Change()
If Len(Me.Text3.Text) > 0 Then
strText3 = Me.Text3.Text
End If
Me.total = strText1 & " " & strText2 & " " & strText3
End Sub

401
สามารถใช้ UpdateQuery ในการอัพเดท Field ที่ต้องการ โดยต้องกำหนดให้ตรงกับ PrimaryKey ด้วยนะครับเช่น
ผมสมมุติว่า Primary Key คือ ID แต่ของคุณผมไม่แน่ใจว่าชื่อ iCustCode หรือเปล่าถ้าใช่ก็เปลี่ยนจาก ID เป็น iCustCode นะครับ

โค้ด SQL ก็จะเป็น

UPDATE tblTransaction INNER JOIN ImPort_Data ON tblTransaction.ID = ImPort_Data.ID SET tblTransaction.tCustItem = [ImPort_Data].iCustPartsCode
WHERE (((tblTransaction.ID)=[ImPort_Data].[ID]));



402
จากอันเก่าปรับโค้ดเป็นแบบนี้นะครับ ไม่ต้องสร้างตารางใหม่
เอาตาราง Temp ออกไปได้เลย

โค๊ด: [Select]
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strWong_Code As String
Dim strMember_Code As String
Dim SQL As String
Set db = CurrentDb()
Set rst = db.OpenRecordset("TB2", dbOpenDynaset)
If Not rst.BOF And Not rst.EOF Then
  rst.MoveFirst
  strWong_Code = rst![วง]
  strMember_Code = rst![สมาชิก]
  rst.MoveNext
 
  Do Until rst.EOF
    If strWong_Code = rst![วง] Then
      strMember_Code = strMember_Code & "," & rst![สมาชิก]
    Else
DoCmd.SetWarnings False
   SQL = "UPDATE TB1 " & _
        "SET samachik= '" & strMember_Code & "'" & _
        "WHERE [รหัส] = '" & strWong_Code & "'"
    DoCmd.RunSQL SQL
      strWong_Code = rst![วง]
      strMember_Code = rst![สมาชิก]
    End If
    rst.MoveNext
  Loop 

DoCmd.SetWarnings False
   SQL = "UPDATE TB1 " & _
        "SET samachik= '" & strMember_Code & "'" & _
        "WHERE [รหัส] = '" & strWong_Code & "'"
    DoCmd.RunSQL SQL
    DoCmd.SetWarnings True
End If
rst.Close
Set rst = Nothing
db.Close
Set db = Nothing

403
ถ้าเป็น text ไม่น่าจะมีปัญหานี้ได้เลย
ขอดู SQL ทั้งอันหน่อยและข้อมูลในตารางด้วย
หรือรีโมทไปแก้ให้ไหมครับ


404
Datatype ของ Field ทำ1 ถึง 5 เป็นประเภทไหนครับ

ส่วน SQL คิวรี่ น่าจะเป็น

SELECT [ทำ1] & " " & [ทำ2] & " " & [ทำ3] & " " & [ทำ4] & " " & [ทำ5] AS ลักษณะการทำประโยชน์, *
FROM ชื่อตาราง;

405
ศึกษาการใช้ Trim ในการตัดช่องว่างครับตัวอย่างในลิ้งนี้

https://www.techonthenet.com/access/functions/string/trim.php

หรือใส่ว่า
FULLNAME: Trim([Name]) & " " & Trim([Surname])
ที่ Column ชื่อ Fullname จะมีการตัดการเว้นวรรคที่เป็นส่วนเกินออกไปทั้ง 2 ฟิลล์ครับ

406
ได้แล้วครับ
Dim chk As Variant
chk = DLookup("[TAG No Barcode]", "[In Process oki]", "[TAG No Barcode] = '" & Me.Text95 & "'")
    If IsNull(chk) Then
       MsgBox "ไม่มีข้อมูล Process ก่อนหน้านี้ "
        Exit Sub
    End If

แต่ถ้าต้องการไม่ให้บันทึกได้แหละครับทำไงคับ ขอบคุณครับ
ใช้ Me.undo ก็ได้ครับ
Dim chk As Variant
chk = DLookup("[TAG No Barcode]", "[In Process oki]", "[TAG No Barcode] = '" & Me.Text95 & "'")
    If IsNull(chk) Then
       MsgBox "ไม่มีข้อมูล Process ก่อนหน้านี้ "
me.undo
        Exit Sub
    End If

407
chk = DLookup("[TAG No Barcode]", "[In Process oki]", "[TAG No Barcode]='" & Me.Text9568 & "'")

ถ้าชื่อมีช่องว่าง ควรมี [] ด้วยนะครับ

408
Dim Chk as String ไปดีกว่าครับ
ควรกำหนดประเภทข้อมูลให้ตัวแปรด้วยเน้อ

409
ห้อง MS Access / : ปิด Subform ใน MS Access
« เมื่อ: 21 ส.ค. 63 , 10:22:22 »
งั้นก็ใช้การกำหนด SourceObject ได้ไหม ลองดูจากกระทู้นี้ครับ ลองโหลดตัวอย่างไปดูครับ
วิธีนี้คือ คิวรี่จะถูกนำมาแสดงเมื่อกดปุ่มครับ

ชื่อฟอร์มหลักชื่อ Main
ชื่อฟอร์มย่อย Subform

Dim QueryName As String
QueryName = "Query." & "ชื่อคิวรี่ที่จะแสดงในฟอร์มย่อย"
Forms("Main").Form.Subform.SourceObject = QueryName

https://www.thai-access.com/index.php?topic=1359.msg5925#msg5925

 

410
สอบถามได้ทำการสร้างฟอร์มขึ้นมาเพื่อเพิ่มข้อมูล แต่อยากให้ก่อนเพิ่มข้อมูลต้องตรวจสอบว่า อีกตารางมีข้อมูลที่กำหนดแล้วหรือไม่ ถ้ามีให้ทำต่อไป ถ้าไม่มีให้มีข้อความแจ้งเตือน
ตามรูปครับ


ใช้ Dlookup check ได้ครับ โดยใช้อีเว้น Afterupdate ครับ โดยใช้โค้ดวิวจากตาราง IN โดยเปรียบเทียบกับ Textbox ของตาราง Out
เช่น if isnull(dlookup("ชื่อฟิลด์","ชื่อตาราง","[Tag no Barcode]='" & me.ชื่อTextboxbarcodeFormout &"'")) then
Msgbox "แจ้งเตือน"
Me.ชื่อTextboxbarcodeFormout.setfocus
Me.ชื่อTextboxbarcodeFormout = Null
End if
ลองดูครับพิมพ์กับโทรศัพท์ยังไม่ได้เทส code เดี๋ยวพรุ่งนี้มาดูให้อีกทีถ้าไม่ได้

411
ห้อง MS Access / : ปิด Subform ใน MS Access
« เมื่อ: 20 ส.ค. 63 , 19:08:15 »
ที่ฟอร์มหลักใน event form open
ใส่โค้ดเพื่อซ่อนซัพฟอร์ม

Private Sub Form_Open(Cancel As Integer)
Me.[ชื่อซัพฟอร์ม].Visible = False
End Sub

หรือ

Form![ชื่อฟอร์มหลัก]![ชื่อซัพฟอร์ม].visible =false

และที่ปุ่มค้นหาเมื่อการค้นหาทำงานก็กำหนดให้
Me.[ชื่อซัพฟอร์ม].visible = True

412
เราสามารถเอาข้อมูลจาก Query Union ไปสร้างเป็น Table ได้ไหมครับ

ได้ Query Union แล้วก็ไปสร้าง MakeTable Query ต่อได้เลยครับ

413
ขอบคุณึครับ  ขอทราบ Event on print คืออะไรครับ  ไม่เคยใช้เลยครับ

ไม่ใช่ on print นะครับ on print จะอยู่ใน Report เน้อ

OnPaint ถ้าจะกำหนดคุณสมบัติ การอ่าน หรือ เขียน เงื่อนไขในส่วนของSection จะใช้อีเว้นนี้ครับ
ไม่ว่าจะกำหนดสี , เส้น หรืออื่นๆ ในส่วน Section ของฟอร์ม

414


ในส่วนของ รายละเอียด หรือ Detail นะครับใส่โค้ดแบบนี้เข้าไป
สมมุติ botton ชื่อ btn1 นะครับ ตรง caption ปล่อยว่างๆไว้
และตรงส่วน Dcount ก็เอาของคุณมาใส่ได้เลย
ใช้ Event OnPaint นะครับ

โค๊ด: [Select]
Private Sub รายละเอียด_Paint()
If Not IsNull(ID) Then
Me.btn1.Caption = "เลือก (" & DCount("[Field]", "[table]", "[ID] =" & [ID] & "") & ")"
End If
End Sub

ID คือ Pk หรือชื่อ Field F-00.. ของคุณนั้นเอง ถ้า ID เป็น string อย่าลืมใส่ single quote ด้วยนะครับ เช่น
โค๊ด: [Select]
Me.btn1.Caption = "เลือก (" & DCount("[Field]", "[table]", "[ID] ='" & [ID] & "'") & ")"


หน้า: 1 ... 20 21 22 [23] 24 25 26 ... 46