MS Access与系统时间设置关系
MS Access and system time settings relation
我有 MS Access 数据库查询条件...Documents.DATE>Date()...
它在一台计算机上运行良好,其中安装了完整的 Access (2016)。
但在我使用 Access Runtime verison(也是 2016)的其他地方,它不起作用。
我已经在具有完整版本的计算机上使用 .accrd 文件尝试过此查询,它也可以正常工作。什么会导致这种行为?
这通常是由于引用丢失造成的。
您可以转到菜单“工具”、“参考”并检查是否有任何参考被标记为“缺失”并解决该问题。但是,由于它是一个运行时,您可能必须创建一个小型测试应用程序来列出具有运行时的机器上的引用。这是一个让您入门的模块:
Option Compare Database
Option Explicit
' Verify Access' external references.
' Returns True if all references are valid.
' Will run quietly, if called with parameter Quiet as True.
'
' Is intended to be called as the first command from the AutoExec macro
' followed by a call to a function - for example CompileAndSave - that will
' "compile and save all modules".
'
' 2018-07-10. Cactus Data ApS, CPH.
'
Public Function VerifyReferences( _
Optional ByVal Quiet As Boolean) _
As Boolean
' Settings for message box.
Const Title As String = "Missing Support Files"
Const Header As String = "One or more supporting files are missing:"
Const Footer As String = "Report this to IT support." & vbCrLf & "Program execution cannot continue."
Const Buttons As Long = VbMsgBoxStyle.vbCritical + VbMsgBoxStyle.vbOKOnly
Dim Reference As Access.Reference
Dim Item As Integer
Dim Guid As String
Dim Major As Long
Dim Minor As Long
Dim Prompt As String
Dim Broken As Boolean
Dim SecondRun As Boolean
Dim Result As Boolean
Do
' Loop (a second time) the references and build a list of those broken.
Broken = False
Prompt = ""
For Each Reference In Access.References
If Reference.BuiltIn Then
' Nothing to check.
ElseIf IsBrokenExt(Reference) Then
Broken = True
Prompt = Prompt & Reference.Guid
On Error Resume Next
Prompt = Prompt & " - " & Reference.Name
On Error GoTo 0
Prompt = Prompt & vbCrLf
End If
Next
If SecondRun Then
' Only shuffle the references once.
Exit Do
ElseIf Not Broken Then
' All references have been verified.
Else
' Try to remove the last non-broken reference and add it back.
' This will shuffle the Reference collection and may or may not
' cause a broken reference to be added back.
Item = Access.References.Count
Do
Set Reference = Access.References.Item(Item)
If Not Reference.BuiltIn Then
If Not IsBrokenExt(Reference) Then
' Record the reference's identification before removal.
Guid = Reference.Guid
Major = Reference.Major
Minor = Reference.Minor
' Remove this reference.
Access.References.Remove Reference
' Add back the removed reference.
Access.References.AddFromGuid Guid, Major, Minor
Exit Do
End If
End If
Item = Item - 1
' Exit loop when a built-in reference is met.
' These are always the top ones.
Loop Until Reference.BuiltIn
SecondRun = True
End If
Loop Until Not Broken
Result = Not Broken
If Result = False And Quiet = False Then
Prompt = Header & vbCrLf & vbCrLf & Prompt & vbCrLf & Footer
VBA.MsgBox Prompt, Buttons, Title
End If
Set Reference = Nothing
VerifyReferences = Result
End Function
' Performs an extended check if a reference is broken, as the
' IsBroken property doesn't check for unregistered files. Thus,
' an unregistered reference may fail even if not marked MISSING.
'
' 2018-07-09. Gustav Brock. Cactus Data ApS.
'
Public Function IsBrokenExt( _
ByRef Reference As Access.Reference) _
As Boolean
Dim NotBroken As Boolean
On Error GoTo Err_IsBrokenExt
' If the reference is not registered, calling property FullPath will fail.
' Even if the file exists in the Virtual File System, GetAttr will find it.
If (VBA.GetAttr(Reference.FullPath) And vbDirectory) <> vbDirectory Then
' FullPath is valid.
NotBroken = Not Reference.IsBroken
End If
Exit_IsBrokenExt:
IsBrokenExt = Not NotBroken
Exit Function
Err_IsBrokenExt:
' Ignore non-existing servers, drives, and paths.
Resume Exit_IsBrokenExt
End Function
我有 MS Access 数据库查询条件...Documents.DATE>Date()... 它在一台计算机上运行良好,其中安装了完整的 Access (2016)。 但在我使用 Access Runtime verison(也是 2016)的其他地方,它不起作用。
我已经在具有完整版本的计算机上使用 .accrd 文件尝试过此查询,它也可以正常工作。什么会导致这种行为?
这通常是由于引用丢失造成的。
您可以转到菜单“工具”、“参考”并检查是否有任何参考被标记为“缺失”并解决该问题。但是,由于它是一个运行时,您可能必须创建一个小型测试应用程序来列出具有运行时的机器上的引用。这是一个让您入门的模块:
Option Compare Database
Option Explicit
' Verify Access' external references.
' Returns True if all references are valid.
' Will run quietly, if called with parameter Quiet as True.
'
' Is intended to be called as the first command from the AutoExec macro
' followed by a call to a function - for example CompileAndSave - that will
' "compile and save all modules".
'
' 2018-07-10. Cactus Data ApS, CPH.
'
Public Function VerifyReferences( _
Optional ByVal Quiet As Boolean) _
As Boolean
' Settings for message box.
Const Title As String = "Missing Support Files"
Const Header As String = "One or more supporting files are missing:"
Const Footer As String = "Report this to IT support." & vbCrLf & "Program execution cannot continue."
Const Buttons As Long = VbMsgBoxStyle.vbCritical + VbMsgBoxStyle.vbOKOnly
Dim Reference As Access.Reference
Dim Item As Integer
Dim Guid As String
Dim Major As Long
Dim Minor As Long
Dim Prompt As String
Dim Broken As Boolean
Dim SecondRun As Boolean
Dim Result As Boolean
Do
' Loop (a second time) the references and build a list of those broken.
Broken = False
Prompt = ""
For Each Reference In Access.References
If Reference.BuiltIn Then
' Nothing to check.
ElseIf IsBrokenExt(Reference) Then
Broken = True
Prompt = Prompt & Reference.Guid
On Error Resume Next
Prompt = Prompt & " - " & Reference.Name
On Error GoTo 0
Prompt = Prompt & vbCrLf
End If
Next
If SecondRun Then
' Only shuffle the references once.
Exit Do
ElseIf Not Broken Then
' All references have been verified.
Else
' Try to remove the last non-broken reference and add it back.
' This will shuffle the Reference collection and may or may not
' cause a broken reference to be added back.
Item = Access.References.Count
Do
Set Reference = Access.References.Item(Item)
If Not Reference.BuiltIn Then
If Not IsBrokenExt(Reference) Then
' Record the reference's identification before removal.
Guid = Reference.Guid
Major = Reference.Major
Minor = Reference.Minor
' Remove this reference.
Access.References.Remove Reference
' Add back the removed reference.
Access.References.AddFromGuid Guid, Major, Minor
Exit Do
End If
End If
Item = Item - 1
' Exit loop when a built-in reference is met.
' These are always the top ones.
Loop Until Reference.BuiltIn
SecondRun = True
End If
Loop Until Not Broken
Result = Not Broken
If Result = False And Quiet = False Then
Prompt = Header & vbCrLf & vbCrLf & Prompt & vbCrLf & Footer
VBA.MsgBox Prompt, Buttons, Title
End If
Set Reference = Nothing
VerifyReferences = Result
End Function
' Performs an extended check if a reference is broken, as the
' IsBroken property doesn't check for unregistered files. Thus,
' an unregistered reference may fail even if not marked MISSING.
'
' 2018-07-09. Gustav Brock. Cactus Data ApS.
'
Public Function IsBrokenExt( _
ByRef Reference As Access.Reference) _
As Boolean
Dim NotBroken As Boolean
On Error GoTo Err_IsBrokenExt
' If the reference is not registered, calling property FullPath will fail.
' Even if the file exists in the Virtual File System, GetAttr will find it.
If (VBA.GetAttr(Reference.FullPath) And vbDirectory) <> vbDirectory Then
' FullPath is valid.
NotBroken = Not Reference.IsBroken
End If
Exit_IsBrokenExt:
IsBrokenExt = Not NotBroken
Exit Function
Err_IsBrokenExt:
' Ignore non-existing servers, drives, and paths.
Resume Exit_IsBrokenExt
End Function