所有功能完成后,VBA关闭访问 [英] VBA close access after all functions finished

查看:123
本文介绍了所有功能完成后,VBA关闭访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从批处理中运行的vba,该批处理启动了一个宏来执行它们,我试图在所有功能完成后关闭访问,但是创建一个新功能并放置 Application.Quit将关闭

I have got vba which I am running from a batch that starts a macro to execute them, I am trying to close down access once all the functions have finished however making a new function and placing "Application.Quit" is closing the application before the functions have finished.

有人有什么想法吗?

谢谢,
Simon

Thanks, Simon

编辑:

Public Function finish()

    Application.Quit

End Function


推荐答案

在代码中放置一个计时器循环,以使数据库进入睡眠状态并为其提供运行时间。

Put a timer loop in your code to put the DB to sleep and give it time for the functions to run.

首先,将其放在任何模块中的Option Compare或Option Explicit行(注意:它必须位于适当的模块中,而不是表单的模块中):

First, put this just under the Option Compare or Option Explicit line in any MODULE (NOTE: it must be in a proper module, and not a form's module):

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

然后您的函数应如下所示:

Then your function should look like this:

Public Function finish()

    Dim X as Integer

    For X = 1 To 10
        Sleep 1000
        DoEvents
    Next X

Application.Quit
End Function

这篇关于所有功能完成后,VBA关闭访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆