แสดงกระทู้

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 - Krathok-man

หน้า: [1] 2
1
ตามนี้ครับ สะดวกดี
โพสต์นี้ได้รับคำขอบคุณจาก: Krathok-man

2
ไฟล์แกะเอาของ ตปท. มาโดยยกโมดูลมาทั้งหมด แล้วปิดส่วนที่ไม่ได้ใช้บางส่วน

หน้าฟอร์มก็ให้เหลือแต่เลือกเครื่องปริ้นครับ
โพสต์นี้ได้รับคำขอบคุณจาก: Krathok-man

3
ไปค้นเจอโพสต์เก่า ตปท. 2017

https://www.experts-exchange.com/articles/30639/Dynamic-Printer-Selection-for-Access.html

ลิงค์โหลดไฟล์ Sample Access Database

ปล.โค้ดเขามัลติฟังก์ชั่น ลองไปแกะหรือรอตามบนครับ
หมายถึงมี Pop-up ขึ้นมาให้เลือกเครื่องพิมพ์ก่อนแล้วกด ตกลง
...
เดี๋ยวจะลองดูนะครับ
โพสต์นี้ได้รับคำขอบคุณจาก: Krathok-man

4
หมายถึงมี Pop-up ขึ้นมาให้เลือกเครื่องพิมพ์ก่อนแล้วกด ตกลง ก่อนจะพิมพ์ใช่ไหมครับ
หลักการน่าจะต้องทำการ ลิสต์รายชื่อเครื่องพิมพ์ที่ติดตั้งในระบบขึ้นมาแสดงใน Combo box
พอเลือกเสร็จก็นำชื่อเครื่องพ์นั้นมา set active  แล้วค่อยสั่ง docmd.openreport ตัวรายงานนั้นๆ
เดี๋ยวจะลองดูนะครับ
โพสต์นี้ได้รับคำขอบคุณจาก: Krathok-man

5
มันเกี่ยวกับโค้ด VBA ที่ใช้กับ Access 32bit แล้วเอาไปใช้กับเครื่องที่เป็น Access 64bit ป่าวคับ
โพสต์นี้ได้รับคำขอบคุณจาก: Krathok-man

6
ห้อง MS Access / : ส่งเป็น excel และเป็น text
« เมื่อ: 20 พ.ค. 64 , 11:05:00 »
จากที่ทดลอง ก็ไม่พบปัญหาที่ว่านี่นะครับ อาจอยู่ที่รุ่นของ Office หรือการตั้งค่า Default ของ Access/Excel

ลองเปลี่ยนเป็นแบบนี้ครับ Export เป็น Excel ยังไงก็เป็น Text

account: IIf([icode]="ABC","'" & "0984455789","")
โพสต์นี้ได้รับคำขอบคุณจาก: Krathok-man

7
ห้อง MS Access / : Window10+Access2003 Missing COMDLG32.OCX
« เมื่อ: 02 พ.ย. 63 , 19:49:58 »
ลองส่งภาพที่แก้ไข path มาให้ผมดูหน่อยครับ ของไฟล์ activex.bat
ของผมก็ windows 10 64 bit ครับใช้งานได้ปกติ

ไฟล์ตัวนี้รู้สึกว่าจะอยู่ใน vb 6.0 นะครับลองโหลดตัวนี้ไปติดตั้งดูด้วย
https://www.microsoft.com/en-us/download/details.aspx?id=10019

Copy OCX ไฟล์ไปไว้

สำหรับ Windows 64-bit แตกไฟล์
OCX ไปที่: C:\Windows\SysWOW64
จากนั้นคลิกขวาที่
Command Prompt กดเลือด (Admin)
แล้วพิมพ์ แบบนี้เข้าไปในหน้าต่าง CMD

regsvr32 comdlg32.ocx

กด ENTER

คลิปฝรั่งสอน
https://youtu.be/1QQDAchjsm0
โพสต์นี้ได้รับคำขอบคุณจาก: Krathok-man

8
ห้อง MS Access / : Window10+Access2003 Missing COMDLG32.OCX
« เมื่อ: 02 พ.ย. 63 , 13:56:08 »
เอาไฟล์ COMDLG32.OCX ไว้ในโฟลเด้อที่โปรแกรมอยู่

หรือดาวน์โหลด ไฟล์ที่ผมส่งไป จะได้ไฟล์ 2 ไฟล์
ที่ไฟล์ชื่อ ActiveX.bat ใช้โปรแกรม NotePad เข้าไปแก้ Path ที่โฟลเดอร์โปรแกรมอยู่เช่น

Regsvr32 C:\MyprogramFloder\COMDLG32.OCX

แล้วกดเซฟ
แล้วกดดับเบิ้ลคลิ๊กที่ ActiveX.bat เพื่อเป็นการ Copy File ไปติดตั้ง

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

9

ลองใช้ .WriteLine แทน .Write ดูครับ
โพสต์นี้ได้รับคำขอบคุณจาก: Krathok-man

10
Shell """c:\program files\7-zip\7z.exe"" a """ & PathString & "\" & "Work.zip" & """ """ & PathString  & "\" & "Work.mdb" & """ "
กรณีข้อความใน PathString มีเครื่องหมาย \ ปิดท้ายอยู่แล้ว ก็ให้เปลี่ยน & "\" & ทั้ง 2 ตำแหน่งเป็น & ก็พอครับ
โพสต์นี้ได้รับคำขอบคุณจาก: Krathok-man

11
ผมจะใช้คำสั่งแบบ command-line ของโปรแกรมที่ทำการ zip ดังนั้นขึ้นกับว่าโปรแกรม zip ที่ใช้นั้น มี command-line หรือไม่ ถ้ามี คำสั่งมีรูปแบบเป็นอย่างไร ส่วนที่ผมใช้คือ 7-zip เวลาสั่ง zip ก็คือ

if dir("drive:\...ชื่อไฟล์.zip") <> "" then kill "drive:\...ชื่อไฟล์.zip" ' ลบ zip เดิมก่อน
shell """c:\program files\7-zip\7z.exe"" a ""drive:\...ชื่อไฟล์.zip"" ""drive:\...ชื่อไฟล์ที่ต้องการ zip"""

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

12
มันขึ้นข้อผิดพลาดทั้งหมายเมื่อก่อนไม่รู้ ตอนนี้ขอติดตั้งเฉพาะแอคเซสอย่างเดียวครับ ต้องทำช้อตคัตไว้หน้าจอเลย...ขึ้นข้อความแปลกๆ ลงใหม่จบ แล้วฝังแอคเซสและอันอื่นๆ ที่น่าจะเชื่อมกันของโปรแกรมไมโครซอฟท์ เรียกใช้จากในพีซี ครับ
โพสต์นี้ได้รับคำขอบคุณจาก: Krathok-man

13
ถ้าโปรแกรมสามารถรันที่เครื่องได้โดยไม่มีปัญหา ก็อาจเป็นไปได้ว่า ใน VBA Editor ที่เมนู Tools - References... บางตัวที่ทำเครื่องหมายเลือกไว้ แต่ปรากฏข้อความว่า Missing แปลว่า library ตัวนั้นหายไป ก็ต้องดูอีกทีว่าตัวไหนหาย ไปก็อปปี้จากเครื่องอื่นมาลง หรือต้องติดตั้งตัว library นั้นใหม่หรือไม่

หรือ registry ของวินโดว์ในส่วนของ Access อาจจะเสีย  หรือไฟล์ที่ Access ใช้บางตัวอาจจะเสียก็ได้ครับ บอกยากเหมือนกัน
โพสต์นี้ได้รับคำขอบคุณจาก: Krathok-man

14
MsgBox "ข้อความ", vbOKCancel + vbDefaultButton2
โพสต์นี้ได้รับคำขอบคุณจาก: Krathok-man

15
ผมสร้าง code ดังนี้  เพื่อไม่ให้ Form BB_detail  รับข้อมูล
 [BB_detail].Form.AllowAdditions = False
 [BB_detail].Form.AllowEdits = False
 [BB_detail].Form.AllowDeletions = False
แต่มันยังกด command btt  ได้  จริงๆ  ผมอยากให้ Disable ทั้งหมด คือสั่งอะไรไม่ได้เลย
เมื่อเกิดเหตุการณ์    มีวิธีอะไรบ้างครับ

ใช้การกำหนด ControlType ครับเช่นต้องการให้ combobox , textbox , commandbotton ไม่ให้สามารถกดแก้ไขได้ ใช้ ctl.Enabled = false

โค๊ด: [Select]
Private Sub Form_Current()
Dim ctl As Control
  For Each ctl In Me
   If ctl.ControlType = acComboBox Then
       ctl.Enabled = False
       ctl.Locked = True
   End If
    If ctl.ControlType = acTextBox Then
       ctl.Enabled = False
       ctl.Locked = True
   End If
    If ctl.ControlType = acCommandButton Then
       ctl.Enabled = False
          End If
         Next ctl
    Forms![BB_detail].Form.AllowAdditions = False
    Forms![BB_detail].Form.AllowEdits = False
    Forms![BB_detail].Form.AllowDeletions = False
End Sub

ControlType แบบต่างๆ
   acBoundObjectFrame      Bound object frame   
   acCheckBox      Check box   
   acComboBox      Combo box   
   acCommandButton      Command button   
   acCustomControl      ActiveX (custom) control   
   acImage      Image   
   acLabel      Label   
   acLine      Line   
   acListBox      List box   
   acObjectFrame      Unbound object frame or chart   
   acOptionButton      Option button   
   acOptionGroup      Option group   
   acPage      Page   
   acPageBreak      Page break   
   acRectangle      Rectangle   
   acSubform      Subform/subreport   
   acTabCtl      Tab   
   acTextBox      Text box   
   acToggleButton      Toggle button   


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

16
ห้อง MS Access / : บังคับให้ Run Notepad Full Screen
« เมื่อ: 03 เม.ย. 63 , 12:07:58 »
    Shell "Notepad.exe " & "D:\Warning.txt", vbNormalFocus
เปิดแล้ว บังคับให้เต็มเจอครับ 
มี Code ที่ทำให้เต็มเจอไหม

ใช้โค้ดอีกหน่อย
โค๊ด: [Select]
Shell "Notepad.exe " & "D:\Warning.txt", vbNormalFocus
Set oShell = CreateObject("WScript.Shell")
oShell.SendKeys "% x"
โพสต์นี้ได้รับคำขอบคุณจาก: Krathok-man

17
เช่น  65.00 อ่านว่า "sixty five bath"  เป็นต้น จนถึงหลักล้าน

สร้าง Module ใส่โค้ดนี้เข้าไป


โค๊ด: [Select]
Public Function wsiSpellNumber(ByVal MyNumber)
    Dim Bath, Stang, Temp
    Dim DecimalPlace, Count
    ReDim Place(9) As String
    Place(2) = " Thousand "
    Place(3) = " Million "
    Place(4) = " Billion "
    Place(5) = " Trillion "
    ' String representation of amount.
    MyNumber = Trim(Str(MyNumber))
    ' Position of decimal place 0 if none.
    DecimalPlace = InStr(MyNumber, ".")
    ' Convert Stang and set MyNumber to dollar amount.
    If DecimalPlace > 0 Then
        Stang = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _
                  "00", 2))
        MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
    End If
    Count = 1
    Do While MyNumber <> ""
        Temp = GetHundreds(Right(MyNumber, 3))
        If Temp <> "" Then Bath = Temp & Place(Count) & Bath
        If Len(MyNumber) > 3 Then
            MyNumber = Left(MyNumber, Len(MyNumber) - 3)
        Else
            MyNumber = ""
        End If
        Count = Count + 1
    Loop
    Select Case Bath
        Case ""
           Bath = "No Bath"
        Case "One"
            Bath = "One Bath"
         Case Else
            Bath = Bath & " Bath"
    End Select
    Select Case Stang
        Case ""
            Stang = " and No Stang"
        Case "One"
            Stang = " and One Stang"
              Case Else
           Stang = " and " & Stang & " Stang"
    End Select
    wsiSpellNumber = Bath & Stang
End Function
     
' Converts a number from 100-999 into text
Function GetHundreds(ByVal MyNumber)
    Dim result As String
    If Val(MyNumber) = 0 Then Exit Function
    MyNumber = Right("000" & MyNumber, 3)
    ' Convert the hundreds place.
    If Mid(MyNumber, 1, 1) <> "0" Then
        result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred "
    End If
    ' Convert the tens and ones place.
    If Mid(MyNumber, 2, 1) <> "0" Then
        result = result & GetTens(Mid(MyNumber, 2))
    Else
        result = result & GetDigit(Mid(MyNumber, 3))
    End If
    GetHundreds = result
End Function
     
' Converts a number from 10 to 99 into text.
Function GetTens(TensText)
    Dim result As String
    result = ""           ' Null out the temporary function value.
    If Val(Left(TensText, 1)) = 1 Then   ' If value between 10-19...
        Select Case Val(TensText)
            Case 10: result = "Ten"
            Case 11: result = "Eleven"
            Case 12: result = "Twelve"
            Case 13: result = "Thirteen"
            Case 14: result = "Fourteen"
            Case 15: result = "Fifteen"
            Case 16: result = "Sixteen"
            Case 17: result = "Seventeen"
            Case 18: result = "Eighteen"
            Case 19: result = "Nineteen"
            Case Else
        End Select
    Else                                 ' If value between 20-99...
        Select Case Val(Left(TensText, 1))
            Case 2: result = "Twenty "
            Case 3: result = "Thirty "
            Case 4: result = "Forty "
            Case 5: result = "Fifty "
            Case 6: result = "Sixty "
            Case 7: result = "Seventy "
            Case 8: result = "Eighty "
            Case 9: result = "Ninety "
            Case Else
        End Select
        result = result & GetDigit _
            (Right(TensText, 1))  ' Retrieve ones place.
    End If
    GetTens = result
End Function
     
' Converts a number from 1 to 9 into text.
Function GetDigit(Digit)
    Select Case Val(Digit)
        Case 1: GetDigit = "One"
        Case 2: GetDigit = "Two"
        Case 3: GetDigit = "Three"
        Case 4: GetDigit = "Four"
        Case 5: GetDigit = "Five"
        Case 6: GetDigit = "Six"
        Case 7: GetDigit = "Seven"
        Case 8: GetDigit = "Eight"
        Case 9: GetDigit = "Nine"
        Case Else: GetDigit = ""
    End Select
End Function

เวลาเรียกใช้ก็ใส่ในคิวรี่ ก็ใส่ EngText:wsiSpellNumber([ชื่อฟิลล์]) หรือ ตัวแปรที่จำให้แสดง

Credit : www.microsoftaccessexpert.com
โพสต์นี้ได้รับคำขอบคุณจาก: Krathok-man

18
ด้านบนเป็นเพียงการเติมอักษรต่อท้ายเลขวันที่ครับ
ส่วนมาโครด้านล่างนี่ผมก็แก้จากชื่อเดือนภาษาไทยเป็นชื่อเดือนภาษาอังกฤษครับ
ตัวอย่างการนำไปใช้งาน =Format(Date(),"d ") & MonthNameEng(Date()) & " " & Year(Date()) = 25 February 2020

โค๊ด: [Select]
Option Compare Database

Public Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long
Public Declare Function GetLocaleInfo Lib "kernel32" _
   Alias "GetLocaleInfoA" _
(ByVal Locale As Long, _
   ByVal LCType As Long, _
   ByVal lpLCData As String, _
   ByVal cchData As Long) As Long

Public Function GetUserLocaleInfo(ByVal dwLocaleID As Long, ByVal dwLCType As Long) As String
   Dim sReturn As String
   Dim r As Long
   r = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))
   If r Then
      sReturn = Space$(r)
      r = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))
      If r Then GetUserLocaleInfo = Left$(sReturn, r - 1)
   End If
End Function

Public Function mYear(ByVal yourDate As Date) As Long
    mYear = Year(yourDate)
    If GetUserLocaleInfo(GetSystemDefaultLCID(), &H1009) = 7 Then mYear = Year(yourDate)
End Function

Public Function bYear(ByVal yourDate As Date) As Long
bYear = Year(yourDate)
'If GetUserLocaleInfo(GetSystemDefaultLCID(), &H1009) <> 7 Then bYear = Year(yourDate) + 543
If GetUserLocaleInfo(GetSystemDefaultLCID(), &H1009) = 7 Then bYear = ((Year(yourDate) + 543) - 2500)
End Function

Function MonthNameEng(ByVal yourDate) As String
    If Not IsNull(yourDate) Then
        yourDate = Format(yourDate, "m")
        Select Case yourDate
            Case 1
               MonthNameEng = "January"
            Case 2
               MonthNameEng = "February"
            Case 3
               MonthNameEng = "March"
            Case 4
               MonthNameEng = "April"
            Case 5
               MonthNameEng = "May"
            Case 6
               MonthNameEng = "June"
            Case 7
               MonthNameEng = "July"
            Case 8
               MonthNameEng = "August"
            Case 9
               MonthNameEng = "September"
            Case 10
               MonthNameEng = "October"
            Case 11
               MonthNameEng = "November"
            Case 12
               MonthNameEng = "December"
            Case Else
               MonthNameEng = ""
        End Select
    End If
End Function


มาแถมถ้าอยากให้มีอักษรต่อท้ายด้วยอีก
1. แก้มาโครแรกให้ FancyDate = FancyDate & Format(dteInput, " ")
2. =FancyDate(Date()) & MonthNameEng(Date()) & " " & Year(Date()) จะได้  25th February 2020
โพสต์นี้ได้รับคำขอบคุณจาก: Krathok-man

หน้า: [1] 2