ACCESS 常用模块

文章目录

    • 删除文件
    • 执行程序
    • 延迟
    • 文件长度
    • 建立文件
    • 文件是否存在
    • 标题常用的命令
    • 消除报警

删除文件

Function kill_file(abcd)
'delete the file
    If IsFileExists(abcd) = True Then
        Kill abcd ' delete 
    End If
End Function

执行程序

Function run_exe_v()
    On Error Resume Next
	' run the exe 
	 f_p = file_path()
    store_path = f_p & "\123.exe"
    ShellExecute Me.Hwnd, "open", store_path, "", "", 1    'run the exe 
End Function

延迟


如果需要延迟时,需要在模块中提前做声明

Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare PtrSafe 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

文件长度


private sub()
        If Len(Text16) <> 0 Then
            If InStr("cell", Text16) = 0 Then
                DoCmd.GoToControl "cell_name"
                DoCmd.FindRecord Text16 & "*"
        End If
   end sub     

建立文件

function Sub Co(file_path,file_content)
        Set file_abc = CreateObject("scripting.filesystemobject")
        Set ntxt = file_abc.opentextfile(file_path, 8, True)
        '????????"d:\n.txt"
            ntxt.writeline file_content
            ntxt.Close
        Set file_abc = Nothing
end function 

文件是否存在

Function run_exe_seaerch_V()
    On Error Resume Next
    f_p = file_path()
    account_n = LCase(Environ("USERNAME"))
    T_path1 = f_p & "\parameter.csv"
    Do Until IsFileExists(T_path1) = True
            Sleep 2000
    Loop

End Function

标题常用的命令

    DoCmd.OpenQuery "Cal_AccessVer_FTP_Up_MOE"
    DoCmd.OpenQuery "Cal_AccessVer_Local_Up_MOE"
    ShellExecute Me.Hwnd, "open", f_p, "", "", 1 'open the folder
    '......copy file to the localtion
    database_path = DLookup("text_p1", "Parameter_access", "Item_Para = '" & "File_path" & "'")
    dd = Format(Date, "YYYY_MM_DD")

复制文件
sourch_file = Application.CurrentProject.Path & “\123.accdb”
copy_name = database_path & “\1234.accdb”
FileCopy copy_name, sourch_file

DoCmd.RunSQL “UPDATE…”

消除报警


Function disable_warning()

DoCmd.SetWarnings False

End Function

你可能感兴趣的:(ACCESS,windows)