แสดงกระทู้

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 - Note Ekkachai

หน้า: [1]
1
Private Sub Form_Open(Cancel As Integer)
    Me.TimerInterval = 150
End Sub

Private Sub Form_Timer()
    Me.TimerInterval = 0
    Me.Image1.picture = Me.pathPic
End Sub

น่าจะพอแก้ขัด  :cool:
โพสต์นี้ได้รับคำขอบคุณจาก: Note Ekkachai

2
ให้เห็นทั้งรูปจากทั้งโฟลเดอร์เก่าและใหม่ อันนี้ผมไม่เคยลองทำเลยครับที่เคยทำก็แค่ DialogPicker ในการเลือกรูป
ปัญหาที่คุยเจอคือพอกล้องอัพรูปลงไปใน Folder เดิมทำให้เกิดการเขียนทับไฟล์เก่าใช่ไหมครับ

ถ้าแบบนี้ให้โปรแกรมทำการ Copy File จาก PicTure โดยเอา SubFloder(Folder วันที่)  มารวมเป็น Folder เดียวกัน
โดยเรากำหนดให้ถ้าเจอไฟล์ซื่อซ้ำกันก็ให้ใส่ (1) (2) เหมือนของ Windows ดีไหมครับ
หรือมีวิธีอื่นๆ ต้องรออาจารย์ท่านอื่นๆ มาแนะนำครับเพราะผมไม่เคยทำเหมือนกันครับ

(ต้องขอโทษที่ตอบช้าครับผมติดสร้างโปรแกรมของหน่วยงานครับ)
โพสต์นี้ได้รับคำขอบคุณจาก: Note Ekkachai

3
อ่อเดียวปรับใหม่คับ
โพสต์นี้ได้รับคำขอบคุณจาก: Note Ekkachai

4
ลองดูตัวอย่างนี้ครับ สมมุติมีชื่อ Folder ใน Folder Picture 2 อันแบบนี้


เมื่อเปิดฟอร์มก็จะจัดเก็บ รายชื่อ SubFolder ลงในตารางและนำมาแสดงใน Combobox


เมื่อเลือก ชื่อ SubFolder แล้วกด Open ก็จะแสดงรูปภาพทั้งหมดที่มีใน SubFolder นั้นขึ้นมาครับ


แสดงตัวอย่างโค้ดทั้งหมด

โค๊ด: [Select]
Option Compare Database
Option Explicit

 Public Function iFileDialog() As String
 Const msoFileDialogFilePicker = 3
 Const msoFileDialogViewDetails = 2
 Dim fd As Object, varltems As Variant, flPath As Variant
 Set fd = Application.FileDialog(msoFileDialogFilePicker)
 With fd
    .Title = "Choose"
    .InitialView = msoFileDialogViewDetails
    .Filters.Clear
    .Filters.Add "Image", "*.jpg;*.png;*.bmp"
    .Filters.Add "All Files", "*.*"
    .FilterIndex = 1
    .InitialFileName = CurrentProject.Path & "\Picture\" & Me.Combo1
    If fd.Show = True Then
        iFileDialog = Trim(.SelectedItems.Item(1))
    End If
  End With
End Function
Sub Create_Dir_List(Inputpath As String)
Dim Dbs As Database
Dim Rst As DAO.Recordset
Dim Fso, Fldr, SubFldr, F As Object
Dim CurrentSubFolderName As String

Set Dbs = CurrentDb
Set Rst = Dbs.OpenRecordset("ListTable", dbOpenDynaset)
Set Fso = CreateObject("scripting.filesystemobject")
Set Fldr = Fso.getfolder(Inputpath)

CurrentSubFolderName = Right$(Fldr.Path, Len(Fldr.Path) - InStrRev(Fldr.Path, "\"))
    With Rst
        .AddNew
        .Fields("FolderName") = CurrentSubFolderName
        .Update
     End With
For Each Fldr In Fldr.subfolders
Call Create_Dir_List(Fldr.Path)
Next Fldr
End Sub
Private Sub Combo1_GotFocus()
Me.Requery
End Sub
Private Sub Find_Click()
Call iFileDialog
End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.SetWarnings False
DoCmd.RunSQL ("delete * from Listtable")
DoCmd.SetWarnings True
Call Create_Dir_List(CurrentProject.Path & "\Picture")
End Sub

โพสต์นี้ได้รับคำขอบคุณจาก: Note Ekkachai

5

.InitialfileName = CurrentProject.Path & "\Picture"

ถ้าเราสร้าง Combobox ขึ้นมาซักตัวเพื่อกำหนดให้แสดง List ของชื่อ Folderวันที่ต่างๆ ที่มีอยู่ใน Picture แล้วกดเปิดตำแหน่งของ Folder นั้นขึ้นมา เพราะท่านได้กำหนดให้แสดงใน Folder Picture แล้ว ถ้าจะกำหนดให้แสดง SubFolder ก็ควรจะมีการกำหนดชื่อของ SubFolder แล้วเปิดขึ้นมาครับ  ถ้าต้องการแบบนี้ เดี่ยวผมทำตัวอย่างให้ดู
โพสต์นี้ได้รับคำขอบคุณจาก: Note Ekkachai

หน้า: [1]