【问题标题】:Microsoft access visual basic automatic every night微软每晚自动访问visual basic
【发布时间】:2017-02-06 06:06:15
【问题描述】:

谁能帮帮我 我有 MS Access 2013 还有Sharepoint online(office 365),我需要从prime Database SQL到SP online,我使用Access来完成它,但它是手动的,我需要在一夜之间自动完成,任何人都知道我们如何做到这一点。 我使用 MS VB 这些是代码:

Option Compare Database

Private Sub DeleteAdd_Click()

  On Error Resume Next

  DoCmd.SetWarnings False
  DoCmd.OpenQuery "DeleteTest", acViewNormal, acEdit
  DoCmd.SetWarnings True
  DoCmd.SetWarnings False
  DoCmd.OpenQuery "AddTest", acViewNormal, acEdit
  DoCmd.SetWarnings True

End Sub

Private Sub lisACTORS_Click()

  MsgBox lisACTORS.Value
End Sub

无论如何我都可以在 VB 或任务计划中完成

【问题讨论】:

  • 例如,您可以尝试使用每小时计时的计时器并检查小时是否等于午夜,然后执行您的代码。

标签: sql vb.net ms-access sharepoint office365


【解决方案1】:

我以前在 Windows 窗体应用程序中做过此操作,我不确定您正在运行什么类型的应用程序。添加一个 Timer 控件,启用计时器并将计时器间隔设置为 60 * 1000 = 60000(相当于一小时)。然后在 Timer.Tick 事件(https://msdn.microsoft.com/en-us/library/system.windows.forms.timer.tick(v=vs.110).aspx)中,写:

If Now.Hour.ToString = "23" Then 'Checks if the current hour is midnight
    'Execute code
End If

【讨论】:

  • 谢谢 Obl,我删除了查询,然后我添加了查询,我需要在一夜之间运行这 2 个查询
  • 所以我放“执行代码”的地方就是你放置删除查询和添加查询的代码的地方。这样,这两件事将在凌晨 12:00 到凌晨 1:00 之间的某个时间发生。您还必须保持程序运行才能使其正常工作。如果我回答了您的问题,我会很感激您将其标记为答案,谢谢。
  • 谢谢 Obl,我尝试了,但我没有成功,仍然无法与我合作
【解决方案2】:

我曾经在几年前的一份工作中这样做过。跟着这些步骤 。 . .

Create an AutoExec macro

If you have already created a macro that contains the actions that you want to occur when the database starts, just rename the macro AutoExec, and it will run the next time that you open the database. Otherwise, follow these steps to create a macro:

    On the Create tab, in the Other group, click Macro. If this command is unavailable, click the arrow beneath either the Module or the Class Module button, and then click Macro.

    In the Macro Builder, in the first empty Action cell, select the action that you want to perform. If applicable, under Action Arguments, type the appropriate values in the argument boxes.

    If you cannot find the action you want, on the Design tab, in the Show/Hide group, make sure Show All Actions is selected. This expands the list of actions that you can use, but the list will include some actions that will only run if the database is granted trusted status. For more information, see the articles Decide whether to trust a database or How database objects behave when trusted and untrusted.

    Repeat step 2 for each additional action you want to occur.

    Click Save, and in the Save As dialog box, type AutoExec.

    Click OK and then close the Macro Builder. The new macro will run the next time that you open the database.

要触发整个事情,您需要使用 Windows 任务计划程序。有关所有详细信息,请参阅下面的链接。

https://www.sevenforums.com/tutorials/11949-elevated-program-shortcut-without-uac-prompt-create.html

如果您对此过程有其他疑问,请回复。

【讨论】:

    猜你喜欢
    • 2013-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多