微软每晚都会自动访问visual basic

时间:2017-02-06 06:06:16

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

任何人都可以帮助我 我有MS Access 2013 和Sharepoint在线(办公室365),我需要从主数据库SQL到SP在线获取数据,我使用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或任务计划

中完成

2 个答案:

答案 0 :(得分: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

答案 1 :(得分:0)

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

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

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