วันอังคารที่ 30 กันยายน พ.ศ. 2557

MS Access : Export File และ เปิดไฟล์

       
เราสามารถ Export File โดยใช้คำสั่ง Docmd.TransferText หรือ Docmd.TransferSpredsheet

DoCmd.TransferText acExportDelim, , "ชื่อ Tabale หรือ Query", "Path และชื่อไฟล์ ที่ต้องการ", True

ตัวอย่าง
DoCmd.TransferText acExportDelim, , "EXP_HISTORY_SUMMARY", "C:\Program Files\Shop \QRYTEST.txt", True

DoCmd.TransferSpreadsheet = Export เป็น Excel File
DoCmd.TransferText = Export เป็น Text File

ถ้าเราต้องการให้ทำการเปิดไฟล์ ใช้คำสั่ง

ตัวอย่าง

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Dim handle As Long
Dim strFileName As String

strFileName = "C:\Program Files\Shop History\QRYTEST.txt"
handle = ShellExecute(0, "Open", strFileName, 0, 0, 1)

0 ความคิดเห็น:

แสดงความคิดเห็น

 
Copyright © . DataJeda Computer Basic - Posts · Comments
Theme Template by DataJeda.com · Powered by DataJeda.com