สร้างปุ่มสำหรับเรียกโฟลเดอร์สำหรับการ แนบไฟล์ แทนการคลิกเลือกที่ฟิลAttachment

เริ่มโดย pondniizz, 23 ต.ค 19 , 15:29:44

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

pondniizz

สอบถามอาจารยบ์ทุกท่านค่ะ

การใช้โค้ดเพื่อสร้างปุ่ม สำหรับ เลือกไฟล์มาไว้ที่ฟิลด์ Attachment โดยได้โค้ดมาดังนี้ค่ะ 

Private Sub Command7_Click()
On Error GoTo Err_AddImage
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim rsChild As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT * FROM Table1")


rst.Edit

Set rsChild = rst.Fields("attachmentTest").Value
    'Add a new attachment.
    filePath = "D:\"
    rsChild.AddNew
    rsChild.Fields("FileData").LoadFromFile (filePath)
    rsChild.Update
    'Update the parent record
    rst.Update
Exit_AddImage:
Set rsChild = Nothing
Set rsParent = Nothing
Exit Sub
Err_AddImage:
If Err = 3820 Then
MsgBox ("File already part of the multi-valued field!")
Resume Next
Else
MsgBox "Some Other Error occured!" & Err.Number & Err.Description
Resume Exit_AddImage
End If
End Sub


แต่ติด Error คะ รบกวนอาจารย์ทุกท่านช่วยหน่อยนะคะ
ความต้องการคือ ต้องการ สร้างปุ่มสำหรับเรียกโฟลเดอร์สำหรับการ แนบไฟล์ แทนการคลิกเลือกที่ฟิลAttachment

ที่มาข้อมูล :https://www.thongjoon.com/2013/07/access-2010.html
  •  

Max

  •